<?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 to feed search result into &amp;quot;custom search command&amp;quot; and get output from custom search command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413722#M119235</link>
    <description>&lt;P&gt;There are many things that can break here, so I just add a list of possible checks:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Did you add &lt;CODE&gt;import splunk.Intersplunk&lt;/CODE&gt; to your script?&lt;/LI&gt;
&lt;LI&gt;What happens if you start the script manually &lt;CODE&gt;$SPLUNK_HOME/bi/splunk cmd python yourscritpnamehere.py&lt;/CODE&gt; any errors?&lt;/LI&gt;
&lt;LI&gt;Did you try the example from the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Customsearchcommandshape#Add_the_Python_script"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Customsearchcommandshape#Add_the_Python_script&lt;/A&gt; does that work?&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Mon, 21 May 2018 22:50:58 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2018-05-21T22:50:58Z</dc:date>
    <item>
      <title>how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413721#M119234</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have written a custom search command to send whois queries for ip addresses that are resulted from search head. I assume that custom search command will get search result from search head and send them whois.arin.net then results will be listed in another field. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;command.conf&lt;/STRONG&gt;  file includes following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[whois]
chunked = true
filename = whois.py
generating = true
supports_rawargs = true
streaming = true
retainsevents = true #!!!!!!  not sure for this !!!!!!!!!!
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;code location:&lt;BR /&gt;
C:\Program Files\Splunk\etc\system\bin&lt;BR /&gt;
code snippet is also following, whole code is working properly out of Splunk, but dont get ant response when running on search head.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;def whoisQuery(orgnames, settings):
    orgnames = []
    orgname = {}
............................................

if "OrgName" in i:
                b = i.split()
                orgname['OrgName'] = b[1:]
                orgnames.append(orgname)
                break
    except:
        pass

    return orgnames         

#to get previous search results     
orgnames, dummyresults, settings = splunk.Intersplunk.getOrganizedResults()     

#for result in orgnames:
orgnames = whoisQuery(orgnames, settings)
splunk.Intersplunk.outputResults(orgnames)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 May 2018 21:57:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413721#M119234</guid>
      <dc:creator>muratogul</dc:creator>
      <dc:date>2018-05-21T21:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413722#M119235</link>
      <description>&lt;P&gt;There are many things that can break here, so I just add a list of possible checks:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Did you add &lt;CODE&gt;import splunk.Intersplunk&lt;/CODE&gt; to your script?&lt;/LI&gt;
&lt;LI&gt;What happens if you start the script manually &lt;CODE&gt;$SPLUNK_HOME/bi/splunk cmd python yourscritpnamehere.py&lt;/CODE&gt; any errors?&lt;/LI&gt;
&lt;LI&gt;Did you try the example from the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Customsearchcommandshape#Add_the_Python_script"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Customsearchcommandshape#Add_the_Python_script&lt;/A&gt; does that work?&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 22:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413722#M119235</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-05-21T22:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413723#M119236</link>
      <description>&lt;P&gt;thanks for response,&lt;BR /&gt;
1. is already ok.&lt;BR /&gt;
2. script run but no result or error, kind of infinite loop&lt;BR /&gt;
3. yes I have two different script one of them is exactly from this sample even if it is not clear how search result being fed into script and how script results being returned to UI screen?&lt;/P&gt;

&lt;P&gt;results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()      &lt;/P&gt;

&lt;P&gt;for result in results:&lt;BR /&gt;
    result["whois"] = whoisQuery(result["_raw"])&lt;BR /&gt;
splunk.Intersplunk.outputResults(results)&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 00:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413723#M119236</guid>
      <dc:creator>muratogul</dc:creator>
      <dc:date>2018-05-22T00:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413724#M119237</link>
      <description>&lt;P&gt;this line &lt;CODE&gt;results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()&lt;/CODE&gt; is reading the previous search results, and this line &lt;CODE&gt;splunk.Intersplunk.outputResults(results)&lt;/CODE&gt; will output the results of your script into Splunk. &lt;/P&gt;

&lt;P&gt;Maybe just start with the example, make that work and then start to change the script logic.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 03:55:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413724#M119237</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-05-22T03:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413725#M119238</link>
      <description>&lt;P&gt;Do this&lt;/P&gt;

&lt;P&gt;results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()&lt;/P&gt;

&lt;P&gt;And then orgnames=results[‘orgNamesField’]&lt;/P&gt;

&lt;P&gt;In your getWhois function, don’t clobber the orgnames object. (orgnames=[]  effectively wipes out what was passed to the function).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;for result in results:
   orgnames=result[‘orgNamesField’]
   result[‘whoisResults’] = getWhois(orgnames)
splunk.Intersplunk.outputResults(results)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 15:05:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413725#M119238</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-05-22T15:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to feed search result into "custom search command" and get output from custom search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413726#M119239</link>
      <description>&lt;P&gt;thanks, make sense. &lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 21:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-feed-search-result-into-quot-custom-search-command-quot/m-p/413726#M119239</guid>
      <dc:creator>muratogul</dc:creator>
      <dc:date>2018-05-22T21:47:51Z</dc:date>
    </item>
  </channel>
</rss>

