Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: how to run a script remotely

Tags:

linux

bash

shell

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.

like image 363
CuriousMind Avatar asked Jan 17 '23 21:01

CuriousMind


1 Answers

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

like image 65
jim mcnamara Avatar answered Jan 25 '23 14:01

jim mcnamara