commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siegfried Goeschl <siegfried.goes...@it20one.at>
Subject Re: some basic defination in common exec
Date Thu, 04 Mar 2010 17:34:31 GMT
Let me check ...

Siegfried Goeschl

On 04.03.10 13:38, maven apache wrote:
> 2010/3/4 maven apache<apachemaven0@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?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message