So I am trying to do following:
- I have Cygwin enabled with screen and ssh daemon in Windows 7.
- I create a new screen using the command
screen -dmS "my_screen"
on my Windows machine. - I ssh to the Windows machine from my Linux machine.
- I attach to it from my unix machine using
screen -d -r my_screen
- Now I try to launch a Windows application, for example notepad.exe.
Now I want to a automate this using Python. The objective is to just manually ssh to Windows and then run a Python script which will do the above steps. I have written the following script but it is not working:
import shlex
import os
import time
import subprocess
cmdString = "screen -d -r default_screen"
cmdArgs=shlex.split(cmdString)
p=subprocess.Popen(cmdArgs)
cmds = "./notepad.exe"
cArgs=shlex.split(cmds)
pp=subprocess.Popen(cArgs)
This is not working. :( Basically to get the screen I will probably need to import pty package or tty. But pty & tty are not supported in Windows. I am able to attach to the newly created screen but then attempt to launch the Windows program like notepad for example fails. It hangs and the windows GUI is not launched as it would when down manually.
I am still exploring this but I will appreciate it if someone can point me to the right way to do it.