SilverStray
Programmer
Hi,
I am having trouble running a shell script from Java, using the Runtime.exec.
In simple illustration, the following code works ok if i execute the class on the same directory as the Shell script "runprog.ksh" is.
String commandScript = "runprog.ksh 'param1'"
final Process process = Runtime.getRuntime().exec(commandScript);
But if i execute the Java class on another machine, and execute the script using ssh, how to properly set or which Runtime.exec(<args>) methods should i use?
I have put something like :
String[] command = {"/etc/ssh myUser@remoteServer","runprog.ksh 'param1'"};
final Process process = Runtime.getRuntime().exec(command);
This results to the following error:
java.io.IOException: java.io.IOException: ssh myUser@remoteServer: not found
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
Pls. help!
Thanks in advance.
SilverStray
I am having trouble running a shell script from Java, using the Runtime.exec.
In simple illustration, the following code works ok if i execute the class on the same directory as the Shell script "runprog.ksh" is.
String commandScript = "runprog.ksh 'param1'"
final Process process = Runtime.getRuntime().exec(commandScript);
But if i execute the Java class on another machine, and execute the script using ssh, how to properly set or which Runtime.exec(<args>) methods should i use?
I have put something like :
String[] command = {"/etc/ssh myUser@remoteServer","runprog.ksh 'param1'"};
final Process process = Runtime.getRuntime().exec(command);
This results to the following error:
java.io.IOException: java.io.IOException: ssh myUser@remoteServer: not found
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
Pls. help!
Thanks in advance.
SilverStray