How to execute one program's output in some different terminal
Question: My last question was also same thing, but did not get proper suggestion, so I
am asking again.

I have a GUI which will connect to ssh. After it connects to ssh I am not able
to do anything , so I have to open new terminal through script do rest of the
operation (display respective outputs ) in that 'new terminal'.

Now I am able to open new window using subprocess but its not taking any
action from GUI may be code issue. Please help me solve my problem.

I am using python and shell script for the backend and wxpython for GUI.

Note: I'm looking for solutions using Python and shell script.

My code is:

    
    
    import time
    import sys
    import pexpect
    c = pexpect.spawn("ssh -Y -L xxxx:localhost:xxxx user @ host.com")
    time.sleep(0.1)
    c.expect("[pP]aasword")
    c.sendline("xxxxxx")
    sub = subprocess.call("xfce4-terminal")
    if sub:
       subprocess.call("svn update",shell=True)
    time.sleep(0.2)
    c.interact()
    c.pexpect([user@host.com~]$)
    # here after its connects to ssh then command wont be executed
    c.sendline("xfce4-terminal")
    

In GUI I have a button "APPLY" and 5 radio button . I can select 1 radio
button at a time and have to click button "APPLY". then it have connect to ssh
tunnel and do the requested operation . Right now it is not allowing to do any
of operation after it gets connect to ssh_tunnel.


Answer: The actual problem that you are seeing is how to avoid blocking the GUI event
loop while you are running `ssh`.

There are two major approaches that allow to solve it:

  * run `ssh` in a background thread and use [an appropriate for your GUI framework method of communicating with the main GUI thread](http://wiki.wxpython.org/LongRunningTasks) to report results.

  * run `ssh` asynchronously and subscribe to its I/O events. Here's [an example for gtk framework](https://gist.github.com/zed/8a255e81eb87431c0e63).

To run commands via `ssh`, you could try to use [`fabric`](http://fabfile.org)
as a [library](http://docs.fabfile.org/en/1.6/usage/library.html) (it is
higher level than `paramiko`).

