How to start a UNIX Shell Script from Java
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kris_Mason
Posted On:   Thursday, June 7, 2001 08:23 AM

I'd like to write a Java application that invokes a UNIX Korn shell script. Thanks for any suggestion on the syntax for starting the shell and passing parameters.

Re: How to start a UNIX Shell Script from Java

Posted By:   Sandip_Chitale  
Posted On:   Sunday, June 10, 2001 05:41 PM

Very basic -

try {
String[] kshCommand =
{
"/bin/ksh"
,"-c"
,"command"
,"command_arg1"
,"command_arg2"
};
java.lang.Process p = java.lang.Runtime.getRuntime().exec(kshCommand);

// deal with stdout, stdin and stderr of the child process using
// p.getInputStream();
// p.getOutputStream();
// p.getErrorStream();

// Now wait for the process completion
p.waitFor();
} catch (IOException ioe) {
}
About | Sitemap | Contact