Thanks for your quick reply and sorry for my late coming since I has been testing the grass command ....<br><br><div class="gmail_quote">2010/3/4 Glynn Clements <span dir="ltr"><<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
maven apache wrote:<br>
<br>
> I want to know the shell used by grass when run it in command line ?<br>
<br>
</div>It uses the shell specified by $SHELL.<br>
<div class="im"><br>
> Because I met a problem when I tried to call grass in my java web<br>
> application,the output of the same cmd are different.<br>
> Details:<br>
> I use the grass-batch-job manner to run the grass in terminal, the<br>
> batjob file is attached as the grass.sh.<br>
<br>
</div>If you set GRASS_BATCH_JOB, it is executed instead of the shell.<br>
<div class="im"><br>
> Then I tried to run it in the java, the java code is shown in the<br>
> attach RuntimeT.java:<br>
<br>
</div><div class="im">> String[] env={"GRASS_BATCH_JOB=/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh"};<br>
> try {<br>
> Process p1=Runtime.getRuntime().exec(cmd, env);<br>
<br>
</div><div class="im">> However when I run this code, the process hang up ,and the output is<br>
> not the same as the terminal, shown in the attach GrassInJava.png.<br>
><br>
> So, what is the problem?<br>
<br>
</div>With java.lang.Runtime.exec(String cmd, String[] envp), the envp<br>
parameter specifies the entire environment for the process (i.e. it<br>
doesn't add the strings to the current process' environment). The<br>
result is that HOME isn't set, which means that $HOME/.grassrc6 cannot<br></blockquote><div>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? <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
be found, so it displays the "first use" screen and waits for the user<br>
to press a key:<br>
<br>
# First time user - GISRC is defined in the GRASS script<br>
if [ ! -f "$GISRC" ] ; then<br>
<br>
if [ ! -f "$GISBASE/locale/$LCL/etc/grass_intro" ] ; then<br>
cat "$ETC/grass_intro"<br>
else<br>
cat "$GISBASE/locale/$LCL/etc/grass_intro"<br>
fi<br>
<br>
echo<br>
echo "Hit RETURN to continue"<br>
read ans<br>
<br>
You should probably retrieve the current environment (which, AFAICT,<br>
requires 5.0 or later; 1.4.2 only appears to allow querying specific<br>
environment variables), and add the GRASS_BATCH_JOB setting to it.<br>
<br>
Beyond that, I'd suggest that you abandon the GRASS_BATCH_JOB approach<br>
and set up the environment yourself, without using the grass64 script<br>
at all.<br></blockquote><div>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.<br>Here I can show you my requirements, can you give me some advise?<br>
---my requirements----<br><br>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).<br>
I have a general idea:<br>
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 <a href="http://r.info">r.info</a>
.....) basing on the set env.<br><br>However I need to solve the following problems:<br>1) how to set up the grass env in java?<br><br>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?<br>
3) As a web application, I should consider the multiple user situation, create a unique gisrc file for each user?<br><br><br>--------------------------<br><br><br><br><br><br><font color="#888888">Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>><br>
</font></div></div><br>