0

I am creating a GUI to facilitate some of the task in UNIX. I would like to launch a process throught Terminal in UNIX. I used the module of

subprocess.Popen()

to launch the process. The problem is that when i launch the process, the process demands the user, their password. I am thinking of creating a window to ask the user for their password. How can i send the password typed in the window to the process launch in the Terminal?

here is the code:

password = wx.TextEntryDialog(None, "What is your password?", 'Password')
    if password.ShowModal() == wx.ID_OK:
        response = password.GetValue()

        command = 'ssh -X pcalcul0 firefox http://qualnetsrv/intraqual//identification.aspx?ref=G0-1427'
        user_manual = subprocess.Popen(command, universal_newlines=True, 
                                       stdin=response,
                                       stdout=subprocess.PIPE, 
                                       stderr=subprocess.STDOUT,
                                       shell=True)
maximus
  • 131
  • 1
  • 2
  • 10

1 Answers1

0

You should be able to use the Pexpect package to do this sort of thing. It has been detailed in other answers such as this one:

Alternatively, you could just create some SSH keys so it automatically logs in.

The other way I know of is to use use Paramiko. Then you can use Python itself to do the SSH / SCP that you need.

Community
  • 1
  • 1
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88