Table of Contents
ctrl-c expect
send ctrl-c
send \003
set timeout 10 spawn ./simv -ucli expect ucli% send {run} ; send "\r" after 3000 send \003 expect ucli% send {run} ; send "\r" after 1000 send \003 interact
pexpect
import time import pexpect child = pexpect.spawn('./simv -ucli') child.expect('ucli%') child.sendline('run 100ns') child.expect('ucli%') child.sendline('run') time.sleep(1) child.sendcontrol('c') child.expect('ucli%') child.sendline('run') time.sleep(1) child.sendcontrol('c') child.interact()
no previous ouput
RUN
child = pexpect.spawn('ls -l') child.expect(pexpect.EOF) print child.before