<?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 Running a CLI  command from Python using paramiko in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/running-a-cli-command-from-python-using-paramiko/m-p/317044#M2228</link>
    <description>&lt;P&gt;I have a very simple python script that uses&amp;nbsp;ssh=paramiko.SSHClient(),&amp;nbsp;ssh.connect (&lt;STRONG&gt;host&lt;/STRONG&gt;, 22, user, password), stdin, stdout, stderr=ssh.exec_command(&lt;STRONG&gt;command&lt;/STRONG&gt;), and&amp;nbsp;for line in stdout.read().splitlines():&amp;nbsp;print(line).&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I set host, user, password and command, e.g. "show ip int brief", to connect to a Cisco router, everything works fine and the script prints out the results that I expect. However, when I set them to connect to a PAN firewall, e.g. command="show clock", my script connects to the FW, which I confirm by looking in the FW's system log, but all I get returned is the&amp;nbsp;'Number of failed attempts since last successful login: 0' message?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas - I'm sure I'm just missing something basic. Do I need to import any of the PAN packages or can I just run run simple CLI commands using paramiko?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I sleep for 20 seconds after connecting before running the ssh.exec_command()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;</description>
    <pubDate>Wed, 18 Mar 2020 13:38:19 GMT</pubDate>
    <dc:creator>johnstoni</dc:creator>
    <dc:date>2020-03-18T13:38:19Z</dc:date>
    <item>
      <title>Running a CLI  command from Python using paramiko</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/running-a-cli-command-from-python-using-paramiko/m-p/317044#M2228</link>
      <description>&lt;P&gt;I have a very simple python script that uses&amp;nbsp;ssh=paramiko.SSHClient(),&amp;nbsp;ssh.connect (&lt;STRONG&gt;host&lt;/STRONG&gt;, 22, user, password), stdin, stdout, stderr=ssh.exec_command(&lt;STRONG&gt;command&lt;/STRONG&gt;), and&amp;nbsp;for line in stdout.read().splitlines():&amp;nbsp;print(line).&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I set host, user, password and command, e.g. "show ip int brief", to connect to a Cisco router, everything works fine and the script prints out the results that I expect. However, when I set them to connect to a PAN firewall, e.g. command="show clock", my script connects to the FW, which I confirm by looking in the FW's system log, but all I get returned is the&amp;nbsp;'Number of failed attempts since last successful login: 0' message?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas - I'm sure I'm just missing something basic. Do I need to import any of the PAN packages or can I just run run simple CLI commands using paramiko?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I sleep for 20 seconds after connecting before running the ssh.exec_command()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 13:38:19 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/running-a-cli-command-from-python-using-paramiko/m-p/317044#M2228</guid>
      <dc:creator>johnstoni</dc:creator>
      <dc:date>2020-03-18T13:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Running a CLI  command from Python using paramiko</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/running-a-cli-command-from-python-using-paramiko/m-p/317169#M2229</link>
      <description>&lt;P&gt;Solved by:&lt;/P&gt;&lt;P&gt;import pandevice&lt;BR /&gt;my_fw = firewall.Firewall(host, user, password)&lt;BR /&gt;response = my_fw.op(command2, xml=True)&lt;BR /&gt;print(response)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The response is a page of XML, so needs to be interpreted, but I do get the answers I want &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 22:06:06 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/running-a-cli-command-from-python-using-paramiko/m-p/317169#M2229</guid>
      <dc:creator>johnstoni</dc:creator>
      <dc:date>2020-03-18T22:06:06Z</dc:date>
    </item>
  </channel>
</rss>

