2 Replies Latest reply: Feb 1, 2007 1:14 PM by 807607 RSS

    invoking a call to a window executable fails when request output to file

    807607
      Hi,

      When invoking a call to a window executable it fails(returns 1 instead of 0) when requesting output to file by using "> filename.txt". This nornally works when run directly within a
      windows command prompt, and it also works if I don't add the "> filename.txt" at the end. Also instead of outputting to a file I would like the same called executable to output to a memory variable that I can extract data without going to a external text file.
      Below is the .java file

      package com.insequence.gv;

      public class Jinvoker {

                public static int invoke(String program) throws java.io.IOException, java.lang.InterruptedException
                {
                     System.out.println("invoking program: " + program);
                     Process p = Runtime.getRuntime().exec(program);
                     int exitValue = p.waitFor();
                     return exitValue;
                }     

                public static void main(String[] argv)
                {
                     try
                     {
                     System.out.println("invoker start");
      //               int retval = invoke("c:\\tvalesky\\java\\invoker\\targetexe arg1 arg2 arg3");
      //               int retval = invoke("C:\\Program Files\\FWTools1.1.0\\bin\\gdalinfo.exe C:\\data\\EarthData2005\\Ortho\\no_collaged.tif");
                     String arg1 = "C:\\data\\EarthData2005\\Ortho\\no_collaged.tif > c:\\testing.txt";
      //               String arg1 = "C:\\data\\EarthData2005\\Ortho\\no_collaged.tif";
                     int retval = invoke("C:\\Program Files\\FWTools1.1.0\\bin\\gdalinfo.exe " + arg1);
      //               int retval = invoke("C:\\Program Files\\FWTools1.1.0\\bin\\gdalinfo.exe");
      //               String arg1 = "-s_srs epsg:26915 -t_srs epsg:4326 C:\\data\\EarthData2005\\Ortho\\no_collaged.tif C:\\data\\EarthData2005\\Ortho\\no_collaged2.tif";
      //               int retval = invoke("C:\\Program Files\\FWTools1.1.0\\bin\\gdalwarp.exe " + arg1);
      //               int retval = invoke("C:\\testing.bat C:\\data\\EarthData2005\\Ortho\\no_collaged2.tif");
                     System.out.println("invoker end: returned " + retval);
                     }
                     catch(java.io.IOException e)
                     {
                          System.out.println("IOException caught: " + e);
                     }
                     catch(java.lang.InterruptedException e)
                     {
                          System.out.println("InterruptedException caught: " + e);
                     }

                }

      }



      Thanks,

      John Mitchell