I am on Ubuntu 12.04 LTS running Python 2.7. My Python code looks somewhat like this:
from os import system
system("screen -S session -X stuff 'commandhere'`echo -ne '\015'`")
But when I try to run it, it does not do anything. I was wondering whether it was possible to fix this, and if so, how?
I am trying to send a command to an active screen "session" where "commandhere" is the command.
Have you tried subprocess.call()
like this:
#!/usr/bin/python
import subprocess
subprocess.call(["screen", "-S", "session", "-X", "stuff", "'command here'`echo -ne '\015'`"])
Another idea: It might be best to just create a bash
script to do the session manipulation stuff and just have Python then call the bash
script.