[GRASSLIST:8361] Remote execution of grass53 commands

Hi all,

First let me give some background information.
I am using grass-5.3.0 on my PC (Pentium P4) running on mandrake 10.0 Linux.
We have few linux PCs (running too on mandrake 10.0) where grass-5.3.0 is
installed.
I am planning to run s.vol.rst module for interpolating daily rainfall values
for some years.
To save time (as it takes considerable time) I wanted to write a script that
will fire a job for diffrent time periods on different PCs from my PC.

The problem starts when I tried to remotely execute the commands from a
script using ssh.

Here is example of the script and output,

-------------------------------------------------------
#!/bin/bash

#First I have to start a grass session on remote machine "chambal"
ssh chambal grass53 /home/suprit/grass53/GrassData/globe/goa
# Then next grass command as.
g.region raster=goa_map_1 (# I tried "ssh chambal g.region raster=goa_map_1"
too.)....
...........
--------------------------------------------------------
This gives out output as shown below, the shell prompt is not returned and the
next command (g.region raster=goa_map_1) does not get executed at all.....
When I kill the Grass session by ctr-c only then g.region gets executed giving
obvious error "ERROR: GISBASE not set"

---output---
Cleaning up temporary files.....$TERM
Starting GRASS ...

tput: No value for $TERM and no -T specified (both -T i specified and

$TERM=xterm here

Welcome to GRASS 5.3.0 (15 May 2004)....
This version running thru the Bash Shell (/bin/bash)
Help is available with the command: g.manual
See the licence terms with: g.version -c
Start the graphical user interface with: tcltkgrass&
When ready to quit enter: exit
|

Am I doing something horribly wrong or there is some settings to be changed?
Any suggestions and help is welcome.

Thanks in advance,
With best regards
Suprit

--
Suprit Kumar
JRF,
National Institute of Oceanography,
Dona Paula-403 004, Goa, INDIA.

email:suprit@nio.org

Tel. : +91-(0)832-2450-400
Fax. : +91-(0)832-2229102
--

Suprit Kumar wrote:

The problem starts when I tried to remotely execute the commands from a
script using ssh.

Here is example of the script and output,

-------------------------------------------------------
#!/bin/bash

#First I have to start a grass session on remote machine "chambal"
ssh chambal grass53 /home/suprit/grass53/GrassData/globe/goa
# Then next grass command as.
g.region raster=goa_map_1 (# I tried "ssh chambal g.region raster=goa_map_1"
too.)....
...........
--------------------------------------------------------
This gives out output as shown below, the shell prompt is not returned and the
next command (g.region raster=goa_map_1) does not get executed at all.....
When I kill the Grass session by ctr-c only then g.region gets executed giving
obvious error "ERROR: GISBASE not set"

---output---
Cleaning up temporary files.....$TERM
Starting GRASS ...
>tput: No value for $TERM and no -T specified (both -T i specified and
$TERM=xterm here

Welcome to GRASS 5.3.0 (15 May 2004)....
This version running thru the Bash Shell (/bin/bash)
Help is available with the command: g.manual
See the licence terms with: g.version -c
Start the graphical user interface with: tcltkgrass&
When ready to quit enter: exit
|

Am I doing something horribly wrong or there is some settings to be changed?
Any suggestions and help is welcome.

The grass53 script starts an interactive shell; it doesn't complete
until you exit the shell.

If you want to run a script within a GRASS session, try:

ssh chambal sh -c '"SHELL=/path/to/script grass53 /home/suprit/grass53/GrassData/globe/goa"'

Alternatively, your script will need to set up the necessary variables
(e.g. GISBASE, GISRC) itself before attempting to run GRASS commands.

For more information, read the grass53 script itself, as well as the
Init.sh script which it calls.

--
Glynn Clements <glynn@gclements.plus.com>

Suprit,

Also, the book "Open Source GIS: A GRASS GIS Approach" has excellent examples of GRASS shell scripting.

Tom

Glynn Clements wrote:

Suprit Kumar wrote:

The problem starts when I tried to remotely execute the commands from a script using ssh.

Here is example of the script and output,

-------------------------------------------------------
#!/bin/bash

#First I have to start a grass session on remote machine "chambal"
ssh chambal grass53 /home/suprit/grass53/GrassData/globe/goa
# Then next grass command as.
g.region raster=goa_map_1 (# I tried "ssh chambal g.region raster=goa_map_1" too.)....
...........
--------------------------------------------------------
This gives out output as shown below, the shell prompt is not returned and the next command (g.region raster=goa_map_1) does not get executed at all.....
When I kill the Grass session by ctr-c only then g.region gets executed giving obvious error "ERROR: GISBASE not set"

---output---
Cleaning up temporary files.....$TERM
Starting GRASS ...
   

tput: No value for $TERM and no -T specified (both -T i specified and
     

$TERM=xterm here

Welcome to GRASS 5.3.0 (15 May 2004)....
This version running thru the Bash Shell (/bin/bash)
Help is available with the command: g.manual
See the licence terms with: g.version -c
Start the graphical user interface with: tcltkgrass&
When ready to quit enter: exit
|

Am I doing something horribly wrong or there is some settings to be changed?
Any suggestions and help is welcome.
   
The grass53 script starts an interactive shell; it doesn't complete
until you exit the shell.

If you want to run a script within a GRASS session, try:

ssh chambal sh -c '"SHELL=/path/to/script grass53 /home/suprit/grass53/GrassData/globe/goa"'

Alternatively, your script will need to set up the necessary variables
(e.g. GISBASE, GISRC) itself before attempting to run GRASS commands.

For more information, read the grass53 script itself, as well as the
Init.sh script which it calls.

--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL: thomas.adams@noaa.gov

VOICE: 937-383-0528
FAX: 937-383-0033

Thanks Glynn and Tom!

I appreciate your timely help and suggestions and hope will be able to write
better scripts following them .
Also I was able to run commands(script) in Grass5.3 non-interactively on a
remote machine using the following as suggested by Glynn.
ssh <remote-machine> sh -c '"SHELL=/path/to/script
grass53 /home/suprit/grass53/GISDBASE/LOCATION/MAPSET"'

With regards,
Suprit

On Wednesday 21 September 2005 00:20, Thomas Adams wrote:

Suprit,

Also, the book "Open Source GIS: A GRASS GIS Approach" has excellent
examples of GRASS shell scripting.

Tom

Glynn Clements wrote:
>Suprit Kumar wrote:
>>The problem starts when I tried to remotely execute the commands from a
>>script using ssh.
>>
>>Here is example of the script and output,
>>
>>-------------------------------------------------------
>>#!/bin/bash
>>
>>#First I have to start a grass session on remote machine "chambal"
>>ssh chambal grass53 /home/suprit/grass53/GrassData/globe/goa
>># Then next grass command as.
>>g.region raster=goa_map_1 (# I tried "ssh chambal g.region
>> raster=goa_map_1" too.)....
>>...........
>>--------------------------------------------------------
>>This gives out output as shown below, the shell prompt is not returned
>> and the next command (g.region raster=goa_map_1) does not get executed
>> at all..... When I kill the Grass session by ctr-c only then g.region
>> gets executed giving obvious error "ERROR: GISBASE not set"
>>
>>---output---
>>Cleaning up temporary files.....$TERM
>>Starting GRASS ...
>>
>>>tput: No value for $TERM and no -T specified (both -T i specified and
>>
>>$TERM=xterm here
>>
>>Welcome to GRASS 5.3.0 (15 May 2004)....
>>This version running thru the Bash Shell (/bin/bash)
>>Help is available with the command: g.manual
>>See the licence terms with: g.version -c
>>Start the graphical user interface with: tcltkgrass&
>>When ready to quit enter: exit
>>
>>
>>
>>Am I doing something horribly wrong or there is some settings to be
>> changed? Any suggestions and help is welcome.
>
>The grass53 script starts an interactive shell; it doesn't complete
>until you exit the shell.
>
>If you want to run a script within a GRASS session, try:
>
>ssh chambal sh -c '"SHELL=/path/to/script grass53
> /home/suprit/grass53/GrassData/globe/goa"'
>
>Alternatively, your script will need to set up the necessary variables
>(e.g. GISBASE, GISRC) itself before attempting to run GRASS commands.
>
>For more information, read the grass53 script itself, as well as the
>Init.sh script which it calls.

--
--
Suprit Kumar
JRF,
National Institute of Oceanography,
Dona Paula-403 004, Goa, INDIA.

email:suprit@nio.org

Tel. : +91-(0)832-2450-400
Fax. : +91-(0)832-2229102
--