May-01-2018, 12:33 AM
while scanning through some old files in an archive, i ran across my very first Python code. i didn't know much about the language at the time. i did use the python command interactively as a calculator a lot even then. but coding this from a similar online template made me more curious what things meant and how it worked.
#!/usr/bin/env python """Get configuration from a Cisco router""" import pexpect import sys child = pexpect.spawn('telnet 192.168.241.1') child.expect('Password: ') child.sendline('rumnnarb') child.expect('#') child.sendline('terminal length 0') child.expect('#') child.sendline('show running-config') child.expect('#') print child.before child.sendline('exit') child.expect('onnection closed') if child.isalive(): child.close()