pexpect

Discussion in 'Python' started by Paul Lemelle, Mar 29, 2008.

  1. Paul Lemelle

    Paul Lemelle Guest

    I am trying separate a script that users pexpect into
    various functions within the same expect session. The
    problem is that the function does not return control
    back Main. Any insight into this issue would be
    greatly appreciated. Below is sample code of the
    problem.

    Thanks,
    Paul
    ____

    import pexpect





    def sshcon(user, password):

    go = pexpect.spawn ('/usr/bin/ssh -l root %s '%
    (user))

    go.expect ('Password: ')

    go.sendline (password)

    go.interact()





    #get node info for both clusters.



    C1_node = raw_input("Enter the ip address for node on
    cluster 1: ")

    C1_pass = raw_input("Enter the password for the node
    on cluster 1: ")





    sshcon(C1_node, C1_pass)

    #The function will not run anything pass this point. If I place the
    #below code into the above funciton than everything works fine.
    chk = pexpect.spawn('ls') # veriy that you are
    connected

    #go to the path

    chk.expect('# ')

    chk.sendline('ls')



    chk.interact(

    #END
     
    Paul Lemelle, Mar 29, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrei

    cannot get pexpect to work

    Andrei, Aug 29, 2003, in forum: Python
    Replies:
    5
    Views:
    558
    Andrei
    Aug 30, 2003
  2. =?ISO-8859-15?Q?J=F6rg?= Maier

    cygwin python with Tkinter and pexpect module

    =?ISO-8859-15?Q?J=F6rg?= Maier, Sep 6, 2003, in forum: Python
    Replies:
    2
    Views:
    539
    =?ISO-8859-15?Q?J=F6rg?= Maier
    Sep 7, 2003
  3. Michael Surette

    pexpect exceptions

    Michael Surette, Jan 26, 2004, in forum: Python
    Replies:
    2
    Views:
    1,022
    Michael Surette
    Jan 28, 2004
  4. Gianluca Trombetta

    pexpect module

    Gianluca Trombetta, May 14, 2004, in forum: Python
    Replies:
    8
    Views:
    3,175
    Adrian Casey
    May 18, 2004
  5. Saqib Ali
    Replies:
    1
    Views:
    362
    Roy Smith
    Dec 26, 2011
Loading...

Share This Page