[GRASS-user] running grass64-svn scripts in sh (OSX)
Jeff Hamann
jeff.hamann at forestinformatics.com
Thu Jul 9 21:13:44 EDT 2009
It's been a few years since I've used GRASS, so please forgive my
rust...
I've created a simple shell script (grasstest.sh) that I need to run
automatically, where the contents are:
echo "attempting to generate classified image for " $1
echo "display the classified the image"
## now run some grass commands
g.version
d.mon start=x0
d.mon sel=x0
g.region rast=LT5040027000626710_B1
d.rast LT5040027000626710_B1
d.mon stop=x0
exit
Then following the instructions for running a grass64 script as a
batch job (http://grass.osgeo.org/wiki/GRASS_and_Shell):
$ export GRASS_BATCH_JOB=/Users/hamannj/Documents/rufus/trunk/bin/
grasstest.sh
then running grass64 from the command line:
$ grass64 -text /Users/hamannj/Documents/rufus/trunk/incoming/drevil/
PERMANENT
results in the following output:
rufus:bin hamannj$ grass64 -text /Users/hamannj/Documents/rufus/trunk/
incoming/drevil/PERMANENT
Cleaning up temporary files ...
Starting GRASS ...
Executing '/Users/hamannj/Documents/rufus/trunk/bin/grasstest.sh' ...
Welcome to GRASS 6.4.0svn (2009)
: command not foundments/rufus/trunk/bin/grasstest.sh: line 14:
: command not foundments/rufus/trunk/bin/grasstest.sh: line 23:
: command not foundments/rufus/trunk/bin/grasstest.sh: line 26:
: command not foundments/rufus/trunk/bin/grasstest.sh: line 30:
attempting to generate classified image for
display the classified the image
: command not foundments/rufus/trunk/bin/grasstest.sh: line 33:
: command not foundments/rufus/trunk/bin/grasstest.sh: line 34:
g.version
'RROR: no such monitor 'x0
>RROR: No such monitor as <x0
. Will try once more
>RROR: No such monitor as <x0
>RROR: No such monitor as <x0
> is not a valid option
Description:
Manages the boundary definitions for the geographic region.
Keywords:
general
Usage:
g.region [-dsplecmn3bgau] [region=name] [rast=name[,name,...]]
[rast3d=name] [vect=name[,name,...]] [3dview=name] [n=value]
[s=value]
[e=value] [w=value] [t=value] [b=value] [rows=value] [cols=value]
[res=value] [res3=value] [nsres=value] [ewres=value] [tbres=value]
[zoom=name] [align=name] [save=name] [--overwrite] [--verbose]
[--quiet]
Flags:
-d Set from default region
-s Save as default region
-p Print the current region
-l Print the current region in lat/long using the current
ellipsoid/datum
-e Print the current region extent
-c Print the current region map center coordinates
-m Print region resolution in meters (geodesic)
-n Print the convergence angle (degrees CCW)
The difference between the projection's grid north and true
north, measured at the center coordinates of the current region.
-3 Print also 3D settings
-b Print the maximum bounding box in lat/long on WGS84
-g Print in shell script style
-a Align region to resolution (default = align to bounds, works
only for 2D resolution)
-u Do not update the current region
--o Allow output files to overwrite existing files
--v Verbose module output
--q Quiet module output
Parameters:
region Set current region from named region
rast Set region to match this raster map
rast3d Set region to match this 3D raster map (both 2D and 3D
values)
vect Set region to match this vector map
3dview Set region to match this 3dview file
n Value for the northern edge
s Value for the southern edge
e Value for the eastern edge
w Value for the western edge
t Value for the top edge
b Value for the bottom edge
rows Number of rows in the new region
cols Number of columns in the new region
res Grid resolution 2D (both north-south and east-west)
res3 3D grid resolution (north-south, east-west and top-bottom)
nsres North-south grid resolution 2D
ewres East-west grid resolution 2D
tbres Top-bottom grid resolution 3D
zoom Shrink region until it meets non-NULL data from this
raster map
align Adjust region cells to cleanly align with this raster map
save Save current region settings in named region file
> not allowed.me. Character <
> not founder map <LT5040027000626710_B1
>ARNING: No such monitor as <x0
: command not foundments/rufus/trunk/bin/grasstest.sh: line 40: exit
: command not foundments/rufus/trunk/bin/grasstest.sh: line 41:
: command not foundments/rufus/trunk/bin/grasstest.sh: line 43:
Closing monitors ...
Cleaning up temporary files ...
Batch job '/Users/hamannj/Documents/rufus/trunk/bin/
grasstest.sh' (defined in GRASS_BATCH_JOB variable) was executed.
Goodbye from GRASS GIS
rufus:bin hamannj$
so I'm not sure why it's not working, but GRASS seems to fire up, run
the batch script, and not accept any commands... and for lines that
contain comments or blank lines, grass throws an error (command not
found).
Eventually, I need to run these from cron, so passing in arguments to
the shell script is required, but for now, I'm hoping to simply run
the script, show some displays, execute some commands, and end the
script.
Thanks for a great app and for any assistance.
Jeff.
Jeff Hamann, PhD
PO Box 1421
Corvallis, Oregon 97339-1421
541-754-2457
jeff.hamann[at]forestinformatics[dot]com
http://www.forestinformatics.com
More information about the grass-user
mailing list