pexpect

Paul Lemelle Plemelle at comcast.net
Sat Mar 29 18:54:32 EDT 2008


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




More information about the Python-list mailing list