Putting things together for Pexpect

As the final step, let's put everything you have learned so far about Pexpect into a script. Putting code into a script makes it easier to use in a production environment, as well as easier to share with your colleagues. We will write our second script, chapter2_2.py.

You can download the script from the book GitHub repository, https://github.com/PacktPublishing/Mastering-Python-Networking-second-edition, as well as looking at the output generated from the script as a result of the commands.
Refer to the following code:
  #!/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 ...

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.