Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 "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?

share|improve this question

migrated from Dec 5 '12 at 11:24

This question came from our site for professional and enthusiast programmers.

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

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.

share|improve this answer

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!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.