1

I am trying to SSH into a remote machine, and run a .ksh file on a that machine to run a Java program.

If SSH into the machine with a tool like Putty, and run this command:

cd /folder/folder/examples; ksh runexample.ksh NameOfClass methodName

The Java program runs its full course, sending some data, putting it into an outside database, and displaying a response. However, if I try to SSH into the machine from the command line on another machine, like so:

/usr/bin/ssh [email protected] "cd /folder/folder/examples; ksh runexample.ksh NameOfClass methodName;"

The program doesn't execute fully. It doesn't give me any errors, but it simply returns notification that the class files were loaded successfully, the first line of the Java program is displayed, then it quits without sending a request or receiving a response.

What are the differences in my two approaches? Any idea of what would be causing this?

1
  • You can try fork it, maybe putty just sends command and quits ssh; try /usr/bin/ssh [email protected] "cd /folder/folder/examples; ksh runexample.ksh NameOfClass methodName &"
    – java_xof
    Dec 4, 2012 at 21:04

2 Answers 2

0

Your shell is exiting before the java command finishes, and killing all the subordinate processes. You need to either rewrite your script so that it waits for the java program to complete, or else rewrite it to allow processes to survive beyond exit.

0

The issue was that I had accidentally included a semi-colon after "methodName" in the SSH command. Interesting to me is that this launched the application, displayed the first line, and then quit without any error messages!

You must log in to answer this question.