June 2017
Intermediate to advanced
446 pages
10h 10m
English
As the final step, let's put everything you learned so far for Pexpect into a script. Putting the code in a script makes it easier to use it in a production environment as well as share the code with your colleagues.
#!/usr/bin/python3 import getpass from pexpect import pxssh devices = {'iosv-1': {'prompt': 'iosv-1#', 'ip': '172.16.1.20'}, 'iosv-2': {'prompt': 'iosv-2#', 'ip': '172.16.1.21'}} commands = ['term length 0', 'show version', 'show run'] username = input('Username: ') password = getpass.getpass('Password: ...Read now
Unlock full access