[GRASS-user] grass shell
maven apache
apachemaven0 at gmail.com
Thu Mar 4 00:48:44 EST 2010
Thanks for your quick reply and sorry for my late coming since I has been
testing the grass command ....
2010/3/4 Glynn Clements <glynn at gclements.plus.com>
>
> maven apache wrote:
>
> > I want to know the shell used by grass when run it in command line ?
>
> It uses the shell specified by $SHELL.
>
> > Because I met a problem when I tried to call grass in my java web
> > application,the output of the same cmd are different.
> > Details:
> > I use the grass-batch-job manner to run the grass in terminal, the
> > batjob file is attached as the grass.sh.
>
> If you set GRASS_BATCH_JOB, it is executed instead of the shell.
>
> > Then I tried to run it in the java, the java code is shown in the
> > attach RuntimeT.java:
>
> > String[]
> env={"GRASS_BATCH_JOB=/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh"};
> > try {
> > Process p1=Runtime.getRuntime().exec(cmd, env);
>
> > However when I run this code, the process hang up ,and the output is
> > not the same as the terminal, shown in the attach GrassInJava.png.
> >
> > So, what is the problem?
>
> With java.lang.Runtime.exec(String cmd, String[] envp), the envp
> parameter specifies the entire environment for the process (i.e. it
> doesn't add the strings to the current process' environment). The
> result is that HOME isn't set, which means that $HOME/.grassrc6 cannot
>
I can not understand, my grass command is "grass64 -text
/home/kk/grass/GrassDataBase/spearfish60/PERMANENT", so I have specified the
location and mapset, the gisrc file is required at any times?
> be found, so it displays the "first use" screen and waits for the user
> to press a key:
>
> # First time user - GISRC is defined in the GRASS script
> if [ ! -f "$GISRC" ] ; then
>
> if [ ! -f "$GISBASE/locale/$LCL/etc/grass_intro" ] ; then
> cat "$ETC/grass_intro"
> else
> cat "$GISBASE/locale/$LCL/etc/grass_intro"
> fi
>
> echo
> echo "Hit RETURN to continue"
> read ans
>
> You should probably retrieve the current environment (which, AFAICT,
> requires 5.0 or later; 1.4.2 only appears to allow querying specific
> environment variables), and add the GRASS_BATCH_JOB setting to it.
>
> Beyond that, I'd suggest that you abandon the GRASS_BATCH_JOB approach
> and set up the environment yourself, without using the grass64 script
> at all.
>
God!, in fact I tied to set up the env vars by myself, however many people
suggest me to use the grass_batch _job for easily using. Now I can not make
a choice.
Here I can show you my requirements, can you give me some advise?
---my requirements----
I am working with the Web Processing Service, and I want to wrap some grass
operation ( for example the buffer , the interpolation and ect...) as
processes in the web service, And my web application is developed by java. I
changed my work platform from win xp to ubuntu beacuase of the unexpected
errors when I call the grass command(Actually I can not do the interpolation
operation in the windows-xp command line, but it can work in the Ubuntu
shell).
I have a general idea:
Create a class named GrassManager, and it contain a method to set the env (a
gisrc file for each user) and a method to call the concrete grass command
(for example r.info .....) basing on the set env.
However I need to solve the following problems:
1) how to set up the grass env in java?
2) after set up the env ,how to call the grass command in java, because it
reffed to command interpreter and separate executable, I do not know the
grass command is either?
3) As a web application, I should consider the multiple user situation,
create a unique gisrc file for each user?
--------------------------
Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100304/a9620285/attachment.html
More information about the grass-user
mailing list