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.
This command works perfectly fine when ran from the nexus CLI and gives me the output I desire:
Command:
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}'
But, when ran from the Python API using the cli() module I am unable to print the results of the command.
Sample Code:
#!/isan/bin/python
import cisco
from cli import *
import re
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}'")
print cdp_nei_state
Error message:
File "/bootflash/cdp_test.py", line 6
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}'")
SyntaxError: unexpected character after line continuation character
Is there a limitation within the cli() module that is prohibiting the command from being ran?