<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read/Pull/Fetch multiple &amp;quot;show commands&amp;quot; out multiple io in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/read-pull-fetch-multiple-quot-show-commands-quot-out-multiple/m-p/4831359#M1014</link>
    <description>&lt;P&gt;Thanks for sharing!&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2023 20:45:04 GMT</pubDate>
    <dc:creator>Alexander Stevenson</dc:creator>
    <dc:date>2023-05-08T20:45:04Z</dc:date>
    <item>
      <title>Read/Pull/Fetch multiple "show commands" out multiple ios devices</title>
      <link>https://community.cisco.com/t5/controllers/read-pull-fetch-multiple-quot-show-commands-quot-out-multiple/m-p/4822981#M1013</link>
      <description>&lt;P&gt;I'd like to share with you this simple and handy script I've written recently without weird and complex symbols and codes.&lt;/P&gt;&lt;P&gt;I hope you find it useful too.&lt;/P&gt;&lt;P&gt;here is how it works:&lt;/P&gt;&lt;P&gt;1- Import the Netmiko package/module for network automation.&lt;/P&gt;&lt;P&gt;2- Input the mgmt ip addresses as a file. (file1)&lt;/P&gt;&lt;P&gt;3- Input the commands as a file.&amp;nbsp; (file2)&lt;/P&gt;&lt;P&gt;4- iterate over all devices, 1 by 1.&lt;/P&gt;&lt;P&gt;5- Input the device information (type, ip, user, pass) by using a dictionary (dict)&lt;/P&gt;&lt;P&gt;6- connect to the current device in dict by using ssh&lt;/P&gt;&lt;P&gt;7- iterate over all commands for the current device in dect. and print the output&lt;/P&gt;&lt;P&gt;Of course, this script can be leveled up with some arranging codes, as this is only the base working code.&lt;/P&gt;&lt;P&gt;Again; I hope you like it and find it useful.&lt;/P&gt;&lt;P&gt;If interested, I'll write and post a script making config changes from an external file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from netmiko import Netmiko

with open('addresses.txt') as f1:
    file1 =f1.read().splitlines()

with open('commands.txt') as f2:
    file2 =f2.read().splitlines()

for device in file1:
    dict = {'device_type':'cisco_ios',
       'ip':device,
       'username':'user1',
       'password':'secret1'
    }
    ssh = Netmiko(**dict)
    for cmd in file2:
        output = ssh.send_command(cmd)
        print(output)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 12:29:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/read-pull-fetch-multiple-quot-show-commands-quot-out-multiple/m-p/4822981#M1013</guid>
      <dc:creator>Odys (CSC)</dc:creator>
      <dc:date>2023-04-27T12:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Read/Pull/Fetch multiple "show commands" out multiple io</title>
      <link>https://community.cisco.com/t5/controllers/read-pull-fetch-multiple-quot-show-commands-quot-out-multiple/m-p/4831359#M1014</link>
      <description>&lt;P&gt;Thanks for sharing!&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 20:45:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/read-pull-fetch-multiple-quot-show-commands-quot-out-multiple/m-p/4831359#M1014</guid>
      <dc:creator>Alexander Stevenson</dc:creator>
      <dc:date>2023-05-08T20:45:04Z</dc:date>
    </item>
  </channel>
</rss>

