<?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 do I run my custom v2 search command script directly from my command prompt? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/626072#M10885</link>
    <description>&lt;P&gt;I wouldn't consider this problem solved. It remains annoyingly hard to run custom search commands from the command line because the protocol is entirely undocumented and no tooling is available.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 00:34:46 GMT</pubDate>
    <dc:creator>spunk_enthusias</dc:creator>
    <dc:date>2023-01-06T00:34:46Z</dc:date>
    <item>
      <title>How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200019#M2694</link>
      <description>&lt;P&gt;I've taken the "generatetext.py" example from the SDK and I'd like to run it directly from my terminal. However, I get the exception below whenever Splunk lib enters  &lt;CODE&gt;_process_protocol_v2&lt;/CODE&gt; and calls  &lt;CODE&gt;self._read_chunk&lt;/CODE&gt; which in turn returns  &lt;CODE&gt;None&lt;/CODE&gt; when it fails to get the "header". &lt;/P&gt;

&lt;P&gt;How do I get around this obstacle in running my custom command script by hand?&lt;/P&gt;

&lt;P&gt;The error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/handlers.py", line 76, in emit
    if self.shouldRollover(record):
  File "/usr/lib64/python2.7/logging/handlers.py", line 155, in shouldRollover
    self.stream.seek(0, 2)  #due to non-posix-compliant Windows feature
  File "/usr/lib64/python2.7/codecs.py", line 703, in seek
    self.stream.seek(offset, whence)
IOError: [Errno 29] Illegal seek
Logged from file search_command.py, line 971
chunked 1.0,239,0
{"inspector":{"messages":[["ERROR","TypeError at \"/home/mat/splunk-sdk-python/examples/searchcommands_app/package/bin/packages/splunklib/searchcommands/search_command.py\", line 650 : 'NoneType' object is not iterable"]]},"finished":true}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2016 01:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200019#M2694</guid>
      <dc:creator>matutter4</dc:creator>
      <dc:date>2016-10-31T01:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200020#M2695</link>
      <description>&lt;P&gt;Here's how I do it:&lt;/P&gt;

&lt;P&gt;/opt/splunk/bin/splunk cmd python /path/to/command.py&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 02:07:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200020#M2695</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-10-31T02:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200021#M2696</link>
      <description>&lt;P&gt;Wait when you say run from your terminal... Do you mean from command prompt or bash using a curl command to post the searh to the Splunk api?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 02:09:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200021#M2696</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-10-31T02:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200022#M2697</link>
      <description>&lt;P&gt;Yes I do mean calling the script like  &lt;CODE&gt;splunk cmd python myscript.py&lt;/CODE&gt; But it just hangs waiting on STDIN. I assume it's looking for headers &amp;amp; metadata. &lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 02:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200022#M2697</guid>
      <dc:creator>matutter4</dc:creator>
      <dc:date>2016-10-31T02:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200023#M2698</link>
      <description>&lt;P&gt;Ok so it's a generating search command yes?&lt;/P&gt;

&lt;P&gt;In this case the only way to test it on command line is with a curl or search cli.&lt;/P&gt;

&lt;P&gt;./splunk search "|generatetext.py"&lt;/P&gt;

&lt;P&gt;For that to work, you must put the command in the /bin folder of at least one app, and make sure that app mentions it properly in the commands.conf&lt;/P&gt;

&lt;P&gt;Here is a link to docs on executing searches via cli:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/CLIsearchsyntax"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/CLIsearchsyntax&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 12:00:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/200023#M2698</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-10-31T12:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/565311#M2699</link>
      <description>&lt;P&gt;is there any alreantive to this for windows?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 11:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/565311#M2699</guid>
      <dc:creator>shuklaji97</dc:creator>
      <dc:date>2021-08-31T11:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run my custom v2 search command script directly from my command prompt?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/626072#M10885</link>
      <description>&lt;P&gt;I wouldn't consider this problem solved. It remains annoyingly hard to run custom search commands from the command line because the protocol is entirely undocumented and no tooling is available.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 00:34:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-run-my-custom-v2-search-command-script-directly-from-my/m-p/626072#M10885</guid>
      <dc:creator>spunk_enthusias</dc:creator>
      <dc:date>2023-01-06T00:34:46Z</dc:date>
    </item>
  </channel>
</rss>

