This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: shell script returning a value


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]