0

Laptop A has python file "file1.py". Computer B has python file "file2.py". I want to remotely enter into Computer B and run the python script file2.py. I am using SCREEN, and below is my code.

import os 
import time

os.system('screen -S Test -d -m /dev/ttyUSB0 57600') 

time.sleep(1)

os.system('screen -S Test -X stuff "file2.py"')   
time.sleep(1)

os.system('screen -S Test -d -r')   
time.sleep(0.25) 

print "done"

1 Answer 1

1

How did you try to run your 'remote' script?

You can try ssh session:

ssh user@computer_b 'python file2.py'

Of course, you should provide a full path to your file2.py script and maybe (I'm not 100% sure) a full path to a Python executable on your remote Computer B. Another option is to make your file2.py executable, by adding a Python "shebang line" as the first line of your file2.py script and setting executable bit via chmod +x file2.py:

Should I put #! (shebang) in Python scripts, and what form should it take?

Sign up to request clarification or add additional context in comments.

6 Comments

ssh may need extra options depending on what file2.py tries to do. For example, a -t option is often needed when using sudo on the remote
I made the changed to the above code..but I still don't get what I want..its not changing directory..how do I define path with gnu-screen?????
I also did.."os.system('screen -S Test -X chdir "/home/user/desktop"') but its not changing the directory.
You don't run your file2.py remotely, as I see from your code. You try to launch file2.py script locally from your Laptop A via screen, but screen doesn't run scripts or programs remotely by itself. You should implement usage of ssh to run scrips remotely.
@mmv I am not using internet for serial communication as I am using RFD 900 radios. Is it possible to do SSH without internet?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.