Hi:
I want to know the shell used by grass when run it in command line ?
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.
-------------------------------------------
r.in.gdal input=/home/kk/grass/data/4404.tif output=aa location=newl >
/home/kk/ttsc.txt
g.gisenv set=LOCATION_NAME=newl
r.buffer input=aa distances=10 output=ab
r.out.gdal input=ab format=GTiff output=/home/kk/grass/data/4404-a.tif
-------------------------------------------
The cmd I run and the output are shown in the attach "output-terminal.txt".
---------------------------------------
kk@ubuntu:~$ export
GRASS_BATCH_JOB=/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh
kk@ubuntu:~$ sudo chmod 777
/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh
[sudo] password for kk:
kk@ubuntu:~$ grass64 -text /home/kk/grass/GrassDataBase/spearfish60/PERMANENT
Cleaning up temporary files ...
Starting GRASS ...
Executing '/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh'
...
Welcome to GRASS 6.4.0RC5 (2009)
Location <newl> created
100%
r.in.gdal complete. Raster map <aa> created.
Reading input raster map <aa@PERMANENT>...
100%
Finding buffer zones...
100%
Writing output raster map <ab>...
100%
Exporting to GDAL data type: Byte
100%
Input raster map contains cells with NULL-value (no-data). The value 255
was used to represent no-data values in the input map. You can specify
nodata value by nodata parameter.
r.out.gdal complete.
Closing monitors ...
Cleaning up temporary files ...
Batch job '/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh'
(defined in GRASS_BATCH_JOB variable) was executed.
Goodbye from GRASS GIS
---------------------------------------
Then I tried to run it in the java, the java code is shown in the
attach RuntimeT.java:
-----------------------------------------
public class RuntimeT {
public static void main(String args) {
String cmd="grass64 -text
/home/kk/grass/GrassDataBase/spearfish60/PERMANENT";
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);
InputStream is=p1.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
String line=null;
for(line=br.readLine();line!=null;line=br.readLine()) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
-------------------------------
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?
(attachments)
output-terminal.txt (1.12 KB)
grass.sh (233 Bytes)
RuntimeT.java (723 Bytes)