[GRASS-user] grass shell

maven apache apachemaven0 at gmail.com
Wed Mar 3 21:34:15 EST 2010


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 at ubuntu:~$ export
GRASS_BATCH_JOB=/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh

kk at ubuntu:~$ sudo chmod 777
/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh
[sudo] password for kk:

kk at 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 at 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?
-------------- next part --------------
kk at ubuntu:~$ export GRASS_BATCH_JOB=/home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh
kk at ubuntu:~$ sudo chmod 777 /home/kk/MavenTest/MParent/mserver/src/main/resources/org/kingxip/grass.sh
[sudo] password for kk: 
kk at 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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grass.sh
Type: application/x-sh
Size: 232 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20100304/5f4e7f21/grass-0001.sh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RuntimeT.java
Type: text/x-java
Size: 722 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20100304/5f4e7f21/RuntimeT-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GrassInJava.png
Type: image/png
Size: 85158 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20100304/5f4e7f21/GrassInJava-0001.png


More information about the grass-user mailing list