Re: some basic defination in common exec
2010/3/4 maven apache apachemav...@gmail.com HI: I want to use common-exec,however I am confusing with some definations - which is the arguments in a cmd to be executed: for example, the cmd I want to execute is : *gdal_tran HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle d:\aa.tif -a_ullr -180 90 180 -90* The gdal_tran is the command name, all of the later are the parameters required, *HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle*-- is the organial data *d:\aa.tif* --- the target file *-a_ullr -180 90 180 -90*-- the option parameters So I want to know which parameter can be added using the commandLine.addArgument() method? Also I have do a test: When I run the command without common-exec, the core codes are shown below: public static void main(String[] args) { String cmd=gdal_translate HDF5:\/home/kk/grass/data/4404.he5\://HDFEOS/GRIDS/OMI_Column_Amount_O3/Data_Fields/ColumnAmountO3 /home/kk/4.tif; Process p1=Runtime.getRuntime().exec(cmd); 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); } -- This code worked well. Then I tried to build the command with common-exec, the core codes are shown below: -- CommandLine line=new CommandLine(gdal_granslate); line.addArgument(HDF5:\/home/kk/grass/data/4404.he5\://HDFEOS/GRIDS/OMI_Column_Amount_O3/Data_Fields/ColumnAmountO3,false).addArgument(/home/kk/4.tif); // here no matter I set the handlQuteo true or false , the result are the same. DefaultExecutor de=new DefaultExecutor(); de.execute(line); // I skip the try . -- Here I got a exception with exit value of 2: - java.io.IOException: Cannot run program gdal_granslate: java.io.IOException: error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at java.lang.Runtime.exec(Runtime.java:593) at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58) at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:302) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:149) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:136) at org.kk.common.CommonExec.AboutQuote(CommonExec.java:16) at org.kk.common.CommonExec.main(CommonExec.java:29) Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.init(UNIXProcess.java:148) at java.lang.ProcessImpl.start(ProcessImpl.java:65) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 8 more - I wonder it is my fault of building the command line?
Re: some basic defination in common exec
I added a similar test to the code base - can you double-check the following snippet? Cheers, Siegfried Goeschl === START OF SNIPPET === CommandLine cl = new CommandLine(gdal_translate); cl.addArgument(HDF5:\/home/kk/grass/data/4404.he5\://HDFEOS/GRID/OMI_Column_Amount_O3/Data_Fields/ColumnAmountO3/home/kk/4.tif, false); DefaultExecutor executor = new DefaultExecutor(); int exitValue = executor.execute(cl); === END OF SNIPPET === On 04.03.10 10:52, maven apache wrote: HI: I want to use common-exec,however I am confusing with some definations - which is the arguments in a cmd to be executed: for example, the cmd I want to execute is : *gdal_tran HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle d:\aa.tif -a_ullr -180 90 180 -90* The gdal_tran is the command name, all of the later are the parameters required, *HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle*-- is the organial data *d:\aa.tif* --- the target file *-a_ullr -180 90 180 -90*-- the option parameters So I want to know which parameter can be added using the commandLine.addArgument() method? - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: some basic defination in common exec
2010/3/5 Siegfried Goeschl siegfried.goes...@it20one.at I added a similar test to the code base - can you double-check the following snippet? Cheers, Siegfried Goeschl === START OF SNIPPET === CommandLine cl = new CommandLine(gdal_translate); cl.addArgument(HDF5:\/home/kk/grass/data/4404.he5\://HDFEOS/GRID/OMI_Column_Amount_O3/Data_Fields/ColumnAmountO3/home/kk/4.tif, false); Here, the /home/kk/4.tif can not connected with the former parameter, there should be a space between them However , this snippet still does not work. DefaultExecutor executor = new DefaultExecutor(); int exitValue = executor.execute(cl); === END OF SNIPPET === On 04.03.10 10:52, maven apache wrote: HI: I want to use common-exec,however I am confusing with some definations - which is the arguments in a cmd to be executed: for example, the cmd I want to execute is : *gdal_tran HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle d:\aa.tif -a_ullr -180 90 180 -90* The gdal_tran is the command name, all of the later are the parameters required, *HDF:d:\data\hdf5\new\m0729_**v003-127.he5://HDFEOS/GRIDS/** Amount_O3/Data_Fields/**SolarZenithAngle*-- is the organial data *d:\aa.tif* --- the target file *-a_ullr -180 90 180 -90*-- the option parameters So I want to know which parameter can be added using the commandLine.addArgument() method? - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org