Posted By:
Adriana_Quero
Posted On:
Wednesday, November 6, 2002 08:21 AM
I have a problem using Runtime.exec() under Linux..I have this code: private void conectarSSH(){ BufferedReader in = null; BufferedReader error = null; String[] command = {"ssh -l adriana leibniz.faces.ula.ve"}; Runtime rt = Runtime.getRuntime(); try{ Process proc = rt.exec(command); String res = new String(); if(proc != null) { in = new BufferedReader(new InputStreamReader(proc.getInputStream())); error = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
More>>
I have a problem using Runtime.exec() under Linux..I have this code:
private void conectarSSH(){
BufferedReader in = null;
BufferedReader error = null;
String[] command = {"ssh -l adriana leibniz.faces.ula.ve"};
Runtime rt = Runtime.getRuntime();
try{
Process proc = rt.exec(command);
String res = new String();
if(proc != null) {
in = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
error = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
while(in.ready()) {
res = res + in.readLine();
System.out.println("SSH " + res);
}
while(error.ready()) {
res = res + error.readLine();
System.out.println("SSH " + res);
}
System.out.println("Response " + res);
proc.waitFor();
if(proc.exitValue() != 0) {
System.err.println("Exit val non zero");
}
}
}catch(Exception e){
e.printStackTrace();
}
}
But I have this Exception:
java.io.IOException: ssh -l adriana leibniz.faces.ula.ve: not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.
(UNIXProcess.java:139)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:550)
at java.lang.Runtime.exec(Runtime.java:475)
at java.lang.Runtime.exec(Runtime.java:441)....
I'm using Red Hat 7.3 and an JApplet
I hope you can help..PLEASE
Thanks a lot..
<<Less