Python Forum
i found my very first Python code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Bar (https://python-forum.io/forum-27.html)
+--- Thread: i found my very first Python code (/thread-9846.html)



i found my very first Python code - Skaperen - May-01-2018

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()