[GRASS-user] How to feed input to grass62 -text?

Dear All,
I raised the following question in Volume 27, Issue 40 of grass digest.

Environment: I have grass6.2.1 on a redhat linux.

Q1. I want to create a location and a mapset via a shell script.

I can create it by invoking

grass in a text mode (or gui interface mode) and then stepping through

several screeens (location ,

mapset input in the 1st screen, projection in the next screen,

bounding box for the region in the

3rd screen and so on). I am wondering whether it is possible to do all

in a script by invoking a

set of commands. If so what should be the sequence of commands.

I am thankful for Glynn Clements and Nikos Alexandris for their input.

Now I have a slightly different version of the question Q1.

  If I invoke in text mode as 'grass62 -text' inside a shell script and
want to feed all input information from that script, will it work? I
tried the following script but it does n't work.

----- begin script ---
#!/bin/sh
set -x
# path to GRASS binaries and libraries:
export GISBASE=/usr/grass-6.2.1
export PATH=$GISBASE/bin:$GISBASE/scripts:$PATH
#for libraries:
export LD_LIBRARY_PATH=/usr/lib:$GISBASE/lib:$LD_LIBRARY_PATH

# run grass in text mode and feed input
/usr/bin/grass62 -text <<GRASSINPUT
TestMapLocation^M
PERMANENT^M
/home/myhome/GRASSDATA^M
^[
y^M
y^M
B^M
y^M
A Test Map Location^M
y^M
y^M
wgs84^M
1^M
40.121141^M
39.839810^M
-75.386610^M
-74.980316^M
^M
^M
^[
y^M
^M
^C
GRASSINPUT

echo "Created a Mapset at
/home/myhome/GRASSDATA/TestMapLocation/PERMANENT\n"
exit
------ end of script -----

When I run I am getting the following error:

----- begin Error Message ---

Cleaning up temporary files.....
Starting GRASS ...
access: No such file or directory
ERROR: LOCATION << /home/myhome/GRASSDATA//TestMapLocation >> not

       available
----- end Error Message ---

Is it possible to make it work this way at all?
Has anybody created a location/mapset like this?

Thanks in advance,
-Karun

Nithi, Nachi K \(Karun\) wrote:

> Q1. I want to create a location and a mapset via a shell script.
I can create it by invoking
> grass in a text mode (or gui interface mode) and then stepping through
several screeens (location ,
> mapset input in the 1st screen, projection in the next screen,
bounding box for the region in the
> 3rd screen and so on). I am wondering whether it is possible to do all
in a script by invoking a
> set of commands. If so what should be the sequence of commands.

I am thankful for Glynn Clements and Nikos Alexandris for their input.

Now I have a slightly different version of the question Q1.

  If I invoke in text mode as 'grass62 -text' inside a shell script and
want to feed all input information from that script, will it work? I
tried the following script but it does n't work.

You can't script the curses startup screen.

If you want to start GRASS non-interactively, you need to specify the
full path to the mapset directory as an argument to the grass62
script.

If you want to create a new mapset, start GRASS in some existing
mapset, create a new mapset with e.g. "g.proj -c", then switch to the
new mapset with g.mapset.

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