<?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 Sending special characters to devices using Python scripts in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818567#M983</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;DIV&gt;sh_data_corr = &lt;SPAN&gt;"show data-corruption"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;try:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;corruption = ConnectHandler.send_command(sh_data_corr)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;the output is:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;% Invalid input detected at '^' marker.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is due to the dash sign. I forget how the commands are sent over the wire to the cisco device. Was it in hex? How should i convert my above command to make it work then?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Thu, 20 Apr 2023 12:20:14 GMT</pubDate>
    <dc:creator>hfakoor222</dc:creator>
    <dc:date>2023-04-20T12:20:14Z</dc:date>
    <item>
      <title>Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818567#M983</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;DIV&gt;sh_data_corr = &lt;SPAN&gt;"show data-corruption"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;try:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;corruption = ConnectHandler.send_command(sh_data_corr)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;the output is:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;% Invalid input detected at '^' marker.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is due to the dash sign. I forget how the commands are sent over the wire to the cisco device. Was it in hex? How should i convert my above command to make it work then?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Apr 2023 12:20:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818567#M983</guid>
      <dc:creator>hfakoor222</dc:creator>
      <dc:date>2023-04-20T12:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818607#M984</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Did you check if you are on the right prompt inside the Cisco device?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This error could happen if you were in 'config t'&amp;nbsp; even if the command were right.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 12:58:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818607#M984</guid>
      <dc:creator>Flavio Miranda</dc:creator>
      <dc:date>2023-04-20T12:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818615#M985</link>
      <description>&lt;P&gt;All my commands are show commands, the rest seem to work fine, except the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| include&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; symbol&amp;nbsp;&lt;/P&gt;&lt;P&gt;commands below don't return any output, and&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;show data-corruption&amp;nbsp; &amp;nbsp; &amp;nbsp;returns the error at mark output.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;sh_bfd = &lt;SPAN&gt;"show bfd neighbors"&lt;BR /&gt;&lt;/SPAN&gt;sh_bootvar = &lt;SPAN&gt;"sh bootvar | include BOOT variable does not exist|CONFIG_FILE does not exist"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# shows if we have boot system image &amp;amp; boot config file saved in memory caches&lt;BR /&gt;&lt;/SPAN&gt;sh_cap_route = &lt;SPAN&gt;"sh capability feature routing | section Disabled"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# outputs disabled routing features&lt;BR /&gt;&lt;/SPAN&gt;sh_clock = &lt;SPAN&gt;"show clock" &lt;/SPAN&gt;&lt;SPAN&gt;# default cisco clock is 24Hour"&lt;BR /&gt;&lt;/SPAN&gt;sh_cpu_report = &lt;SPAN&gt;"sh monitor event-trace cpu-report brief back 110:00"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# needs to be configured with process cpu on node or return empty string&lt;BR /&gt;&lt;/SPAN&gt;sh_data_corr = &lt;SPAN&gt;"show data-corruption" &lt;/SPAN&gt;&lt;SPAN&gt;# checks data inconsistency errors&lt;BR /&gt;&lt;/SPAN&gt;sh_logging = &lt;SPAN&gt;"show logging | include [A-Z]+-[0-4]" &lt;/SPAN&gt;&lt;SPAN&gt;#shows log severity 3 or above&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;#we will extract logging level 0-4 in the last 5 days, let the node parse the regex&lt;BR /&gt;&lt;/SPAN&gt;sh_mem_failure = &lt;SPAN&gt;"sh memory failures alloc | include \S+.*[0-9]"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;#the [0-9] returns any memory failures detected, or an empty string&lt;BR /&gt;&lt;/SPAN&gt;sh_int_down = &lt;SPAN&gt;"sh ip int brief" &lt;/SPAN&gt;&lt;SPAN&gt;# regex 'if err-disabled'&lt;BR /&gt;&lt;/SPAN&gt;sh_cef = &lt;SPAN&gt;"show cef state"&lt;BR /&gt;&lt;/SPAN&gt;sh_mem_total = &lt;SPAN&gt;"show memory free totals | include (Processor).*[0-9]" &lt;/SPAN&gt;&lt;SPAN&gt;# parses second line of memory cache&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I changed PyCharms global and file encodings to both ASCII and UT-8 and it doesn't seem to solve it.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Apr 2023 13:09:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818615#M985</guid>
      <dc:creator>hfakoor222</dc:creator>
      <dc:date>2023-04-20T13:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818618#M986</link>
      <description>&lt;P&gt;also&amp;nbsp;&lt;SPAN&gt;sh_mem_total&amp;nbsp; &amp;nbsp;seems to work as the dash symbol is inside brackets:&amp;nbsp; [-]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sh_logging =&amp;nbsp;"show logging | include [A-Z]+-[0-4]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;returns error at mark output&amp;nbsp; as dash symbol is outside of brackets. I'm thinking it&amp;nbsp; might be parsing the - symbol as a range?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 13:11:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818618#M986</guid>
      <dc:creator>hfakoor222</dc:creator>
      <dc:date>2023-04-20T13:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818645#M987</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 13:56:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818645#M987</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-04-20T13:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818655#M988</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 14:19:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818655#M988</guid>
      <dc:creator>hfakoor222</dc:creator>
      <dc:date>2023-04-20T14:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sending special characters to devices using Python scripts</title>
      <link>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818713#M989</link>
      <description>&lt;P&gt;After all that work and yes, I should've been under enable. it is working now.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 15:30:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/sending-special-characters-to-devices-using-python-scripts/m-p/4818713#M989</guid>
      <dc:creator>hfakoor222</dc:creator>
      <dc:date>2023-04-20T15:30:07Z</dc:date>
    </item>
  </channel>
</rss>

