[GRASSLIST:5922] grass5 non-interactively

Hello,

I would like to ask how to run grass5, execute a perl script in it and exit it non-interactively (e.g. from crontab). I have tried to edit ~/.grass5.bashrc (copied the .bashrc file saved in the location/mapset directory and added perl script execution line and 'exit' command), but it doesn't work now.

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.

Could anybody help me? Thanks

     Miroslav
____________________________________________________________
Miroslav Sedivy http://www.slovensko.com
miro@slovensko.com ... Your Guide to Slovakia

Miroslav Sedivy wrote:

I would like to ask how to run grass5, execute a perl script in it and
exit it non-interactively (e.g. from crontab). I have tried to edit
~/.grass5.bashrc (copied the .bashrc file saved in the location/mapset
directory and added perl script execution line and 'exit' command),
but it doesn't work now.

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

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

At Mon, 31 Mar 2003 10:50:17 +0100 Glynn Clements wrote:

Hello Glynn,

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...

thanks for your help
cheers
  Stephan Holl

--
Stephan Holl

GnuPG Key-ID: 11946A09

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@virgin.net>