<?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 Nexus 3K|9K: Python API - cli() module not running command/providing output in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/nexus-3k-9k-python-api-cli-module-not-running-command-providing/m-p/3848263#M1864</link>
    <description>&lt;P&gt;I am in the process of writing a post validation script utilizing the Pythong API that runs natively on NXOS and am having some issues using the "cli()" module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This command works perfectly fine when ran from the&amp;nbsp; nexus CLI and gives me the output I desire:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Command:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = "" ; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when ran from the Python API using the cli() module I am unable to print the results of the command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample Code:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/isan/bin/python&lt;BR /&gt;import cisco&lt;BR /&gt;from cli import *&lt;BR /&gt;import re&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cdp_nei_state = cli("show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = ""; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print cdp_nei_state&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error message:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File "/bootflash/cdp_test.py", line 6&lt;BR /&gt;cdp_nei_state = cli("show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = ""; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'")&lt;BR /&gt;&lt;BR /&gt;SyntaxError: unexpected character after line continuation character&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a limitation within the cli() module that is prohibiting the command from being ran?&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2019 22:41:07 GMT</pubDate>
    <dc:creator>r.guillory</dc:creator>
    <dc:date>2019-04-30T22:41:07Z</dc:date>
    <item>
      <title>Nexus 3K|9K: Python API - cli() module not running command/providing output</title>
      <link>https://community.cisco.com/t5/controllers/nexus-3k-9k-python-api-cli-module-not-running-command-providing/m-p/3848263#M1864</link>
      <description>&lt;P&gt;I am in the process of writing a post validation script utilizing the Pythong API that runs natively on NXOS and am having some issues using the "cli()" module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This command works perfectly fine when ran from the&amp;nbsp; nexus CLI and gives me the output I desire:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Command:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = "" ; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when ran from the Python API using the cli() module I am unable to print the results of the command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample Code:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/isan/bin/python&lt;BR /&gt;import cisco&lt;BR /&gt;from cli import *&lt;BR /&gt;import re&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cdp_nei_state = cli("show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = ""; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print cdp_nei_state&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error message:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File "/bootflash/cdp_test.py", line 6&lt;BR /&gt;cdp_nei_state = cli("show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = ""; FS = "\n" }{print $1,"\t"$2,"\n"$3,"\t"$4,"\n"$5,"\t""\t""\t"$6"\n"$7,"\t""\t""\t"$8}'")&lt;BR /&gt;&lt;BR /&gt;SyntaxError: unexpected character after line continuation character&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a limitation within the cli() module that is prohibiting the command from being ran?&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 22:41:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/nexus-3k-9k-python-api-cli-module-not-running-command-providing/m-p/3848263#M1864</guid>
      <dc:creator>r.guillory</dc:creator>
      <dc:date>2019-04-30T22:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Nexus 3K|9K: Python API - cli() module not running command/providing output</title>
      <link>https://community.cisco.com/t5/controllers/nexus-3k-9k-python-api-cli-module-not-running-command-providing/m-p/3848429#M1865</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;You need to escape all those double quotes. Try using this command string:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;show cdp neighbors | exclude 'Cap|Switch|VoIP|STP|Tot' | awk '{print $1}' | awk 'BEGIN{ RS = \"\"; FS = \"\n\" }{print $1,\"\t\"$2,\"\n\"$3,\"\t\"$4,\"\n\"$5,\"\t\"\"\t\"\"\t\"$6\"\n\"$7,\"\t\"\"\t\"\"\t\"$8}'&lt;/PRE&gt;
&lt;P&gt;...the string should then correctly parse in the interpreter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers,&lt;/P&gt;
&lt;P&gt;Seb.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 09:55:18 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/nexus-3k-9k-python-api-cli-module-not-running-command-providing/m-p/3848429#M1865</guid>
      <dc:creator>Seb Rupik</dc:creator>
      <dc:date>2019-05-01T09:55:18Z</dc:date>
    </item>
  </channel>
</rss>

