Hi guyz.
My challenge is that I can manually run the following command from linux shell:
sh /usr/bin/sshlogin.sh 192.168.0.37|danga|dan1ga|java -jar /shared/smsfiles/coin/MySSH.jar
successfully.
The challenge from java is getting the same command to run.
The snippet of my code that handles this is as follows, though it does not run as expected:
public void runCron(String job)
{
System.out.println("Inside runCron...");
Runtime r = Runtime.getRuntime();
Process p = null;
String opt1 = "sh", opt2 = "/usr/bin/sshlogin.sh", opt3 = "192.168.0.37|danga|dan1ga|java"
,opt4= "-jar",opt5="/shared/smsfiles/coin/MySSH.jar";
String [] commands = {opt1, opt2, opt3, opt4, opt5};
if(job != null)
{
try
{
p = r.exec(commands);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String str = "";
while ((str = br.readLine()) != null)
{
System.out.println(str);
}
br.close();
p.waitFor();
} catch (Exception e)
{
System.out.println("Exception "+e.getMessage());
System.err.println("Exception "+e.getMessage());
}
}
}//runCron
I'm guessing maybe that the pipe character ,|, is the root cause of this whole issue but then again I may be wrong.
Someone kindly assist me.
Thanks you all.