I can run a shell script on remote machine with ssh. For example:
ssh -l foo 192.168.0.1 "`cat my_script.sh`"
Now I want to run a python script without sending .py file. Is there any way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will put the contents of my_script.py on your computer into an echo command that is performed on the remote computer and passed into python.
If you want to add command line args it should be as simple as putting them after the python command like so:
Make sure that the command line args are inside the double quotes of the command you are sending to the remote host.