04-20-2023 05:20 AM
I'm writing some scripts, and i noticed when sending special characters, namely the dash sign "-", to show commands on Cisco devices I am getting bad outputs.
for example:
Solved! Go to Solution.
04-20-2023 05:58 AM
Hello,
Did you check if you are on the right prompt inside the Cisco device?
This error could happen if you were in 'config t' even if the command were right.
04-20-2023 05:58 AM
Hello,
Did you check if you are on the right prompt inside the Cisco device?
This error could happen if you were in 'config t' even if the command were right.
04-20-2023 06:07 AM - edited 04-20-2023 06:09 AM
All my commands are show commands, the rest seem to work fine, except the
| include - symbol
commands below don't return any output, and
04-20-2023 06:11 AM
also sh_mem_total seems to work as the dash symbol is inside brackets: [-]
but
sh_logging = "show logging | include [A-Z]+-[0-4]
returns error at mark output as dash symbol is outside of brackets. I'm thinking it might be parsing the - symbol as a range?
04-20-2023 06:56 AM
I think i saw this or something like it years back with Napalm. In the end i created an alias command on the device. As you noted the other stuff works, and i found work arounds for the pipe command. Dirty trick, but it did work.
04-20-2023 07:11 AM - edited 04-20-2023 07:19 AM
That's really interesting. For now I want to avoid aliases. I might try plain Python IDE instead of Pycharm if I can't find a way for it to work.
I tried it in the Python console from the system, and same exact issue. The best guess I have on my mind right now is default encodings in windows not doing what i want it to do. Not being able to use special characters takes a lot of usability of of the scripts, so I have to find a workaround
04-20-2023 08:30 AM
After all that work and yes, I should've been under enable. it is working now.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide