Implementing a "screen" command for windows machine using python
Question: So I am trying to do following:

  1. I have _Cygwin_ enabled with _screen_ and _ssh daemon_ in _Windows 7_.
  2. I create a new screen using the command `screen -dmS "my_screen"` on my _Windows_ machine.
  3. I _ssh_ to the _Windows_ machine from my _Linux_ machine.
  4. I attach to it from my unix machine using `screen -d -r my_screen`
  5. 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.


Answer: I put the screen command in the bash profile script of cygwin user. This is
working now.

