I am trying to use pexpect to dump long ACLs to Cisco IOS router, the ACL contents are in a string, which has about 100 lines of ACL entries, I used the following code:
for aclstr_line in aclstr.split('\n\r'):
ssh_session.sendline('%s' % aclstr_line)
ssh_session.expect('[(.+)#]')
ssh_session.interact()
ssh_session.sendline('interface vlan100')
ssh_session.expect('[(.+)#]')
ssh_session.sendline('ip access-group Inbound_ACL in')
ssh_session.expect('[(.+)#]')
The above first 5 lines of code works perfectly until ssh_session.interact(), but if I take off "ssh_session.interact()", the code breaks, logfile shows that the code does not complete configuring all ACL entries before proceeding to execute rest sendline commands, all sendline commands seem to be mixed with each other.
What could be the cause? thanks,