Note that there are some explanatory texts on larger screens.

plurals
  1. POPop up message box after connecting to SSH
    primarykey
    data
    text
    <p>Hi all I am learning Python and making a GUI model using wxPython.</p> <p>I want to connect vai SSH, I am used pexpect for this purpose. I want to display a msg box saying, "Connected to server" or if disconnected, "connection not established" I am cannot figure out how to do this and the GUI freezes when it connects. How do I avoid freezing the GUI? My sample code is:</p> <pre><code>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") #time.sleep(0.2) c.interact() c.pexpect([user@host.com~]$) </code></pre> <p>After its connects to SSH here, the GUI freezes. After connecting, I want show the connection status in a message box, not in terminal. Please suggest how to do it; as a beginner I find it difficult.</p> <p>Thanks in advance. </p> <h1>Update:</h1> <pre><code>import wx import os import pexpect import sys import subprocess import time class Connect_ssh(wx.Frame): def __init__ (self, *args, **kw): wx.Frame.__init__(self,None,wx.ID_ANY,"Secure Shell", size=(310,200),style=wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.RESIZE_BORDER) panel = wx.Panel(self) txt1 = wx.StaticText(panel, label="Account name:",pos=(20, 55)) txt2 = wx.StaticText(panel, label="Password",pos=(20, 105)) self.txt_name = wx.TextCtrl(panel, -1, size=(130, -1), pos=(160,50)) self.txt_pswd= wx.TextCtrl(panel, -1, size=(130, -1),pos= (160,100),style=wx.TE_PASSWORD) button1 = wx.Button(panel, -1, "Connect",size=(-1,-1), pos=(50, 160)) button2 = wx.Button(panel, -1, "Disconnect",size=(-1,-1), pos=(170, 160)) self.Bind(wx.EVT_BUTTON,self.OnConc,button1) def OnConc(self,event): u_name = self.txt_name.GetValue() passwd = self.txt_pswd.GetValue() child = pexpect.spawn("ssh -Y -L xxx:localhost:xxx %s@host.com" % (str(u_name))) child.expect("%s@host.com's password:" % (str(u_name)) ) child.sendline("%s" % (str(passwd))) child.interact() #child.sendline("%s" % str(sub)) child.expect("[%s@qvislabs.com~]$"% (str(u_name)) ) #time.sleep() #self.Destroy() msg = wx.MessageBOx(" '%s'@host.com is connected" % (str(u_name)), "Info",wx_OK) self.Hide() if __name__=="__main__": app = wx.App() Connect_ssh().Show() app.MainLoop() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload