Multiple commands on remote machine using shell script

后端 未结 3 522
遇见更好的自我
遇见更好的自我 2020-12-01 12:30

I have a Java program Desktop/testfolder/xyz.jar on a remote machine. It has a configuration file on the same folder. When I SSH into the machine, I do:

相关标签:
3条回答
  • 2020-12-01 12:33

    If you want to split your commands over multiple lines for the sake of readability, you could also pass the list of commands to the bash command as follows:

    ssh user@remote.host bash -c "'
      cd Desktop/testfolder
      java -cp xyz.jar Main
    '"
    
    0 讨论(0)
  • 2020-12-01 12:45

    Try something like this:

    ssh you@yours.com "cd /home && ls -l"
    
    0 讨论(0)
  • 2020-12-01 12:49

    You could try separating the commands by a semicolon:

    ssh user@remote "cd Desktop/testfolder ; java -cp xyz.jar Main"
    
    0 讨论(0)
提交回复
热议问题