tags:

views:

36

answers:

2

Hello all, I have a java program Desktop/testfolder/xyz.jar on a remote machine. It also has a configuration file on the same folder. When I ssh to the machine i do "ssh user@remote java -cp Desktop/testfolder/xyz.jar Main" The problem here is the configuration file is not in the path as we are in the home folder so my program cannot readup the configuration.

So I want to first go into that folder and then run the program from that folder. In a shell script if I did this "ssh user@remote cd Desktop/testfolder" "java -cp xyz.jar Main"

it executes the first statement and when the second statement is run it runs on my current machine not the remote machine.

Can we do only one command or there are any other solutions for this ?

Thank you, Lalith

+1  A: 

You could try separating the commands by a semicolon:

ssh user@remote "cd Desktop/testfolder ; java -cp xyz.jar Main"
Trey
+1  A: 

Try something like this:

ssh [email protected] "cd /home && ls -l"

??

Robin
Thanks both of your comments helped !
Lalith
You're welcome! Trey's and my answer do the same thing provided the first part of the command "works" - the version with the
Robin