delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/09/21:15:17

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-Id: <5.1.0.14.2.20010709180845.027ded00@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Mon, 09 Jul 2001 18:15:00 -0700
To: "SAWANT,SACHIN (Non-HP-PaloAlto,ex1)" <sachin_sawant AT non DOT hp DOT com>,
"'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: Java Runtime.exec()
In-Reply-To: <2F5BD88EB480D3119E35009027AF99B50174A13D@xpa03.corp.hp.com
>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019