I have developed a web application ( deployed on a weblogic server ) , I want to connect to the solaris server and execute a shell script with a specific unix user. At present , the script runs with a wls user. Here's the portion of my code :
String CLA="-d";
out.println("Stopping ASAP for the changes to reflect ...");
ProcessBuilder processBuilder = new ProcessBuilder("/bin/ksh","/apps/vpn/asap/scripts/stop_asap_sys_tool"+" "+CLA);
process = processBuilder.start();
InputStream is = process.getInputStream();
InputStream isErr = process.getErrorStream();
InputStreamReader isr = new InputStreamReader(is);
InputStreamReader isrErr = new InputStreamReader(isErr);
BufferedReader br = new BufferedReader(isr);
BufferedReader brErr = new BufferedReader(isrErr);
String line;
String lineErr;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
while ((lineErr = brErr.readLine()) != null) {
System.out.println(lineErr);
}
My search result suggests to use Jsch. Can some one give me an example with respect to my implementation on using Jsch. Or any other way of doing it ?!
THanks , Bhavin