Results 1 to 1 of 1
- 09-28-2011, 01:04 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
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]Java 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(); } } }
Thanks,
Kumar Raj
Similar Threads
-
Debugging a Java Code which is run by a Shell Script
By ArunJava in forum New To JavaReplies: 0Last Post: 09-12-2011, 03:21 PM -
Running a Python Script in Java
By JavaN00bie in forum New To JavaReplies: 6Last Post: 06-22-2011, 09:23 PM -
Java Applet Shell script
By karthikm897 in forum Java AppletsReplies: 5Last Post: 08-18-2009, 04:42 AM -
How to generate auto shell script using java..
By balakrishna in forum Advanced JavaReplies: 8Last Post: 12-30-2008, 06:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks