Running shell script and c binery in remote system from windows using java
Hi,
I have an shell script program in a remote linux machine which will do some specific monitoring functionality. Also, have some C executables in that machine.
From a windows machine, I want to run the shell script program (If possible using java).
I tried with SSH for this. but, in terminal of that linux machine, the c executable process pts shown as ? mark. The C executable does not run.
But, if run the C executable in the system directly, it is running properly.
In windows system, java program, I exported DISPLY=:0.0,
but same problem in executing remote problem.
Can you help me on this.
I am using "sshxcute" third party open source ssh application.
Code as follows,
Code:
package RemoteExecute;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import net.neoremind.sshxcute.core.ConnBean;
import net.neoremind.sshxcute.core.SSHExec;
import net.neoremind.sshxcute.task.CustomTask;
import net.neoremind.sshxcute.task.impl.ExecCommand;
import net.neoremind.sshxcute.task.impl.ExecShellScript;
public class RExecute {
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmdExe);
int exitVal = proc.exitValue();
System.out.println("Process exitValue: " + exitVal);
} catch (Throwable t)
{
t.printStackTrace();
}
}
*/
public static void main(String args[])
{
try
{
// Initialize a ConnBean object, parameter list is ip, username, password
ConnBean cb = new ConnBean("10.114.10.97", "jai","jai123");
// Put the ConnBean instance as parameter for SSHExec static method getInstance(ConnBean) to retrieve a singleton SSHExec instance
Object ssh = SSHExec.getInstance(cb);
// Connect to server
((SSHExec) ssh).connect();
CustomTask sampleTask = new ExecCommand("export DISPLAY=:0.0");
((SSHExec) ssh).exec(sampleTask);
CustomTask ct1 = new ExecShellScript("/home/jai/scripts/test2.sh");
((SSHExec) ssh).exec(ct1);
CustomTask ct2 = new ExecShellScript("/home/jai/program/CTest");
((SSHExec) ssh).exec(ct2);
((SSHExec) ssh).disconnect();
} catch (Throwable t)
{
t.printStackTrace();
}
}
}
[\code]
Thanks,
Kumar Raj