tags:

views:

868

answers:

2

I want to run a script remotely. But the system doesn't recognize the path. It complains that "no such file or directory "Am i using it right?

ssh kev@server1 `./test/foo.sh`
+2  A: 

Backticks will run the command on the local shell and put the results on the command line. What you're doing is saying 'execute ./test/foo.sh and then pass the output as if I'd typed it on the commandline here'. Try ssh kev@server1 './test/foo.sh', and make sure that thats the path from your home directory on the remote computer to your script.

Edited for clarity.

Edit: Also, the script has to be on the remote computer. What this does is essentially log you into the remote computer with the listed command as your shell. You can't run a local script on a remote computer like this (unless theres some fun trick I don't know).

psanf
Here's the fun trick, taken from http://wpkg.org/Executing_local_programs_and_scripts_remotely: cat /usr/bin/program | ssh user@server "cat > /tmp/program ; chmod 755 /tmp/program ; /tmp/program --arguments"
Mark Rushakoff
psanf
A: 

I don't know if it's possible to run it just like that.

I usually first copy it with scp and then log in to run it.

scp foo.sh user@host:~
ssh user@host
./foo.sh
Macarse