Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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)" , "'cygwin AT cygwin DOT com'" From: Randall R Schulz Subject: Re: Java Runtime.exec() In-Reply-To: <2F5BD88EB480D3119E35009027AF99B50174A13D@xpa03.corp.hp.com > Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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/