[GRASSLIST:6111] Re: grass5 non-interactively

Glynn Clements glynn.clements at virgin.net
Tue Apr 22 23:57:58 EDT 2003


Stephan Holl wrote:

> >  The location/mapset environment variables are correctly defined, the
> > > grass5 starts without the initial dialogue and gets immediately to
> > > grass shell, but then it does not run my perl script.
> > 
> > Setting the environment variable SHELL to the path to the perl script
> > should work, e.g.
> > 
> > 	SHELL=/path/to/script.pl grass5 /path/to/dbase/location/mapset
> 
> with reference to this old thread I cannot make grass work as a
> non-interactive session from cron.
> I would like to run some simple commands like g.list rast without any
> user-interaction.
> this is the shell-script:
> #!/bin/sh
> g.list rast >> raster-files.txt
> exit
> 
> but the above SHELL-command does not produce any output...

AFAIK, cron parses the command lines itself, rather than just passing
the entire text to the shell, so the above syntax wouldn't work.
Setting SHELL separately might work, i.e.:

	SHELL=/path/to/script
	grass5 /path/to/dbase/location/mapset

Also, the grass5 script is typically installed in /usr/local/bin,
which might not be in cron's PATH setting. In that case, you would
have to provide the full path, i.e.

	SHELL=/path/to/script
	/usr/local/bin/grass5 /path/to/dbase/location/mapset

There may well be further issues related to the fact that the
environment of processes which are spawned by cron is more sparse than
that of a typical interactive shell. An interactive shell normally has
its environment extended by startup scripts (including, but not
limited to, /etc/profile, ~/.profile, /etc/bashrc, ~/.bash_profile,
~/.bash_login and ~/.bashrc). Some of the settings contained in those
files may be necessary for GRASS to operate. You can use the "env"
command to determine which environment variables are actually set.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list