[GRASS-user] Script fails; manual entry works

Moritz Lennert mlennert at club.worldonline.be
Wed Sep 18 13:36:25 PDT 2019


Le Wed, 18 Sep 2019 13:22:22 -0700 (PDT),
Rich Shepard <rshepard at appl-ecosys.com> a écrit :

> I've a script that begins this way:
> 
> #!/usr/bin/bash
> 
> # Create projection and exit
> # LDQ-45123G3:
> grass79 -c LDQ-45123G3/2009_OLC_Hood\ to\
> Coast/Bare_Earth/be45123g3/prj.adf /data/grassdata/g3 -e
> 
> grass79 g3/PERMANENT
> sleep 1s
> r.in.gdal in=LDQ-45123G3/2009_OLC_Hood\ to\
> Coast/Bare_Earth/be45123g3/hdr.adf out=45123g3_hood_to_coast
> mem=16000 --o r.import in=LDQ-45123G3/2009_OLC_Hood\ to\
> Coast/Bare_Earth/be45123g3h/hdr.adf out=45123g3h_hood_to_coast
> resamp=lanczos_f mem=16000 --o r.import
> in=LDQ-45123G3/2009_OLC_Willamette\
> Valley/Bare_Earth/be45123g3/hdr.adf out=45123g3_willamette_valley
> resamp=lanczos_f mem=16000 --o r.import
> in=LDQ-45123G3/2009_OLC_North\ Coast/Bare_Earth/be45123g3/hdr.adf
> out=45123g3_north_coast resamp=lanczos_f mem=16000 --o r.import
> in=LDQ-45123G3/2015_ODF_NW\
> Oregon-McGregor/Bare_Earth/be45123g3/hdr.adf
> out=45123g3_oregon_mcgregor resamp=lanczos_f mem=16000 --o exit
> 
> When I run the script, and kill it after a minute or so this is the
> console display:
> 
> GRASS 7.9.dev (g3):/data/grassdata > exit
> exit
> Cleaning up temporary files...
> Done.
> 
> Goodbye from GRASS GIS
> 
> ./process-lidar-dems-row-g.sh: line 12: r.in.gdal: command not found
> ./process-lidar-dems-row-g.sh: line 13: r.import: command not found
> ./process-lidar-dems-row-g.sh: line 14: r.import: command not found
> ./process-lidar-dems-row-g.sh: line 15: r.import: command not found
> ./process-lidar-dems-row-g.sh: line 16: r.import: command not found
> 
> However, when I block each of the first 4 lines in the script (other
> than the sleep command) grass processes r.in.gdal andr.import without
> throwing the 'command not found' error.
> 
> What have I done incorrectly which breaks the script at line 9 (I've
> redacted a few lines in this version)?

You cannot launch GRASS GIS within the script in this way. You have to
put the actual module calls into a script and then either

- launch GRASS GIS and from the GRASS command line launch the script, or
- follow
  https://grasswiki.osgeo.org/wiki/GRASS_and_Shell#GRASS_Batch_jobs,
  i.e. let the GRASS_BATCH_JOB variable point to your script

Moritz


More information about the grass-user mailing list