Govi
Govi

Reputation: 1

Python script does not run after logging into computer remotely using "Screen"

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"

Upvotes: 0

Views: 103

Answers (1)

mmv
mmv

Reputation: 11

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?

Upvotes: 1

Related Questions