Reputation: 51
When I do this
ssh host@someip "cd /target && ls"
the files on remote machine are displayed.
Now, I am trying to run a file on the remote machine.
ssh host@someip "cd /target && ./file.sh"
When i do this it reaches the folder named target on the remote machine but the file is executed on local machine. How to make file.sh also run on remote machine ?
Upvotes: 0
Views: 1701
Reputation: 25956
It depends where do you initialize your libraries on the remote server. There are several possibilities, which can be wrong, but without exact error, it is impossible to guess:
Your ~/.bashrc
(or other startup files) do not load libraries for non-interactive jobs. You can force TTY allocation:
ssh -t host@someip "cd /target && ./file.sh"
You might initialize libraries with in some other script. You can load it before running your script:
ssh host@someip "source your_init_file && cd /target && ./file.sh"
Upvotes: 2