Mail Archives: cygwin/2001/07/09/21:15:17
Sachin,
If that's literally the code you're executing, the most obvious problem is
the argument to rt.exec(...). If those quotation marks are in there, get
rid of them, turning a string literal into a variable reference, which is
certainly what you intended.
And you'll be on to your next problem. I think you'd be better of not
assuming anything about the working directory of a Java program, since it's
not a defined aspect of the Java Runtime Environment. It would probably be
better to set the PATH environment (also not specified, but it will work on
any system where Runtime.exec(...) will work) to include the directory
(-ies) that contain commands you need to execute.
Lastly, keep in mind that there is no Cygwin-enabled JVM, so CLASSPATH and
file name and command syntax, etc. will have to be Windows native, not
Cygwin style.
Randall Schulz
At 18:03 2001-07-09, SAWANT,SACHIN (Non-HP-PaloAlto,ex1) wrote:
>Hi,
>
>We are using cygwin to run our application. I am trying to execute a shell
>file at the operation system through java. The code is as follows
>
>
> String unixCommand = "./run.sh";
> Runtime rt = Runtime.getRuntime();
> Process proc = rt.exec("unixCommand");
>
> InputStream result = proc.getInputStream();
> InputStreamReader isr = new InputStreamReader(result);
> BufferedReader br = new BufferedReader(isr);
> String line = null;
>
> while ( (line = br.readLine()) != null)
> out.println(line);
>
> int exitVal = proc.waitFor();
>
>
> I am getting CreateProcess Exception when I try to run this code. It does
>work well for other unix commands like "ls" or "ps". Am I doing something
>wrong?
>
>
>Regards
>
>Sachin
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -