<?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 Re: How can I use tab-completion &amp;amp; command history in the python that is packaged with Splunk? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620171#M10839</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;thanks for your answer!&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have tested on a handful of our splunk instances, and all of them have the same behavior:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;splunk python (v3.7.11)&lt;UL&gt;&lt;LI&gt;arrow keys nav/history -&amp;nbsp;does not work&lt;/LI&gt;&lt;LI&gt;tab-completion -&amp;nbsp;does not work&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;server python (v2.7.5) -&amp;nbsp;&lt;UL&gt;&lt;LI&gt;arrow keys nav/history - works by default&lt;/LI&gt;&lt;LI&gt;tab-completion -&amp;nbsp;does not work by default; works after this:&amp;nbsp;&lt;A href="https://stackoverflow.com/a/246779" target="_blank" rel="noopener"&gt;https://stackoverflow.com/a/246779&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;in the splunk python cli, readline &amp;amp; rlcompleter modules are not present:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;splunk@host1:~ $ ./bin/splunk cmd python
Python 3.7.11 (default, Jul 27 2022, 02:48:51)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import readline
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
ModuleNotFoundError: No module named 'readline'
&amp;gt;&amp;gt;&amp;gt; import rlcompleter
&amp;gt;&amp;gt;&amp;gt; readline.parse_and_bind("tab: complete")
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
NameError: name 'readline' is not defined
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so no arrow keys or tab-completion &lt;span class="lia-unicode-emoji" title=":tired_face:"&gt;😫&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 18:21:34 GMT</pubDate>
    <dc:creator>anirban_td</dc:creator>
    <dc:date>2022-11-08T18:21:34Z</dc:date>
    <item>
      <title>How can I use tab-completion &amp; command history in the python that is packaged with Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620155#M10837</link>
      <description>&lt;P&gt;Hello splunkers,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I use tab-completion &amp;amp; command history in the python that is packaged with Splunk?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The python version [./bin/splunk cmd python] with Splunk Enterprise v9 is 3.7.11&lt;BR /&gt;However, there is no tab-completion or command history..&amp;nbsp;&lt;/P&gt;&lt;P&gt;tab is interpreted as 4 whitespace, while up/down arrow key is&amp;nbsp;interpreted as&amp;nbsp;^[[A or&amp;nbsp;^[[B.&amp;nbsp;&lt;BR /&gt;even simple cursor positioning using right/left arrow keys are interpreted as&amp;nbsp;[[D^ OR [[C^..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(dev2) splunk@host1:~ $ ./bin/python3
Python 3.7.11 (default, Jul 27 2022, 02:48:51)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; ^[[A
  File "&amp;lt;stdin&amp;gt;", line 1
    ^
SyntaxError: invalid syntax
&amp;gt;&amp;gt;&amp;gt; ^[[B
  File "&amp;lt;stdin&amp;gt;", line 1

    ^
SyntaxError: invalid syntax
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a simple requirement to have quick &amp;amp; dirty troubleshooting for python commands. Its a major pain to not have access to history or not being able to use L/R arrow keys to move cursor.&lt;/P&gt;&lt;P&gt;Please help.&amp;nbsp;&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 16:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620155#M10837</guid>
      <dc:creator>anirban_td</dc:creator>
      <dc:date>2022-11-08T16:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use tab-completion &amp; command history in the python that is packaged with Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620163#M10838</link>
      <description>&lt;P&gt;FWIW, the cursor keys work as expected on one of my systems and not so well on the other.&amp;nbsp; On the system where cursor don't work, the behavior is the same for both the Splunk-supplied and system-installed Python interpreters.&amp;nbsp; It could be how the terminal definitions are set up on each system, but I didn't go into it that far.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 17:01:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620163#M10838</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-08T17:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use tab-completion &amp; command history in the python that is packaged with Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620171#M10839</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;thanks for your answer!&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have tested on a handful of our splunk instances, and all of them have the same behavior:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;splunk python (v3.7.11)&lt;UL&gt;&lt;LI&gt;arrow keys nav/history -&amp;nbsp;does not work&lt;/LI&gt;&lt;LI&gt;tab-completion -&amp;nbsp;does not work&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;server python (v2.7.5) -&amp;nbsp;&lt;UL&gt;&lt;LI&gt;arrow keys nav/history - works by default&lt;/LI&gt;&lt;LI&gt;tab-completion -&amp;nbsp;does not work by default; works after this:&amp;nbsp;&lt;A href="https://stackoverflow.com/a/246779" target="_blank" rel="noopener"&gt;https://stackoverflow.com/a/246779&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;in the splunk python cli, readline &amp;amp; rlcompleter modules are not present:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;splunk@host1:~ $ ./bin/splunk cmd python
Python 3.7.11 (default, Jul 27 2022, 02:48:51)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import readline
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
ModuleNotFoundError: No module named 'readline'
&amp;gt;&amp;gt;&amp;gt; import rlcompleter
&amp;gt;&amp;gt;&amp;gt; readline.parse_and_bind("tab: complete")
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
NameError: name 'readline' is not defined
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so no arrow keys or tab-completion &lt;span class="lia-unicode-emoji" title=":tired_face:"&gt;😫&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 18:21:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-use-tab-completion-amp-command-history-in-the-python/m-p/620171#M10839</guid>
      <dc:creator>anirban_td</dc:creator>
      <dc:date>2022-11-08T18:21:34Z</dc:date>
    </item>
  </channel>
</rss>

