Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <5.1.0.14.2.20020212113934.023851f0@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 12 Feb 2002 11:55:34 -0800 To: John Albert , cygwin AT cygwin DOT com From: Randall R Schulz Subject: Re: shell script returning a value In-Reply-To: <99E5EB82CE45D511845F00508BE95B4C2A8F9E@CTPNT002> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed John, I hope this reaches you in time to solve your very urgent problem. There is nothing Cygwin-specific about this. Java.lang.Runtime.exit(int status) is available as always, and the exit status code of the Java program will be returned to its invoker just as it would if a C program or a shell script was invoked instead of a Java program. In the reverse, where Java invokes the sub-process (your case), Process.exitValue() allows you to retrieve the exit status of the sub-process once it terminates. Again, whether or the sub-process is a Cygwin executable or a "native" Windows program (including another Java program) and if it is a Cygwin program whether it's a binary or a shell script is all irrelevant--exit values are propagated uniformly by any of these variants to each other. However, you should note that if your Java program is to invoke a shell script interpreted by a Cygwin shell (or, for that matter, Perl or Python or any other interpeter), there will be no #! interpretation done on the script file, since the invocation of the sub-process from the JVM is done using Windows native APIs, not the Cygwin POSIX emulation of exec(). You will have to invoke the shell explicitly and pass it arguments that cause that shell to run your script. Randall Schulz Mountain View, CA USA At 11:24 2002-02-12, John Albert wrote: >Hi, > >Can anyone help me? > >Is it possible to return a value from a shell script? > >I'm using a Java program to execute a shell script. To that Java program >[the] shell script has to return a value. -- Is it possible? > >[This is] very urgent. > >Please tell me your suggestions. > > >Thanks. > >John -- 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/