Bash: how to run a script remotely

bash, linux, shell

Solution

chmod +x ./run.py
scp -pq  ./run.py 10.1.100.100:'/home/myremotedirectory/run.py'
ssh 10.1.100.100     'cd /somedirectory  &&  /home/myremotedirectory/run.py'

See if that helps

Problem

I have a script (say `run.py`) and I want to scp that to a remote machine (say `10.1.100.100`), cd into a directory in that remote machine, and execute `run.py` in that directory. How do I wrap the above procedure in one single bash script? I don't know how to let bash execute commands remotely in another machine. Hopefully I can see that stdout of `run.py` in my terminal. But if I can only redirect it, that's fine as well.

Original source

Related problems