I use pexpect to spawn a telnet session and perform some auto-login. It's strange that if child process runs before the parent, I see all telnet inputs echo back (include the password), but after I add some order-control logic, that behavior just disappears:
add a method to pexpect.spawn:
def __continue_handler(self, sig, data):
self.continue_flag = True
within _spawn, add these before calling pty.fork:
self.continue_flag = False
add this just when the child process starts:
while not self.continue_flag: time.sleep(1)
and these before parent's _spawn exits:
I don't know why but this really works.
Log in to post a comment.