pexpect

P

Paul Lemelle

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top