<?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 pass values (dynamically derived from event) to a Python script as command line arguments? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284391#M3553</link>
    <description>&lt;P&gt;@MuS I used the same &lt;BR /&gt;
results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults()&lt;BR /&gt;
 to grab the events from search results  but it doesnt work ?&lt;/P&gt;

&lt;P&gt;any ideas ?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 01:10:41 GMT</pubDate>
    <dc:creator>aab5272</dc:creator>
    <dc:date>2017-07-14T01:10:41Z</dc:date>
    <item>
      <title>How to pass values (dynamically derived from event) to a Python script as command line arguments?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284389#M3551</link>
      <description>&lt;P&gt;Can I pass values (dynamically derived from event) to a Python script as command line arguments, do some magic in the script, and pass the new values back to Splunk? isp.outputResults(results)?&lt;/P&gt;

&lt;P&gt;I tried this, but in the script, the argument is interpreted like a string. I mean the script knows just the name of the string, not the value!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 11:43:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284389#M3551</guid>
      <dc:creator>nikkkc</dc:creator>
      <dc:date>2016-02-18T11:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass values (dynamically derived from event) to a Python script as command line arguments?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284390#M3552</link>
      <description>&lt;P&gt;Hi nikkkc,&lt;/P&gt;

&lt;P&gt;take a look at the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.8/AdvancedDev/SearchScripts#Build_your_search_command_in_Python"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.8/AdvancedDev/SearchScripts#Build_your_search_command_in_Python&lt;/A&gt; to learn more about this topic. The important part is to import &lt;CODE&gt;splunk.Intersplunk&lt;/CODE&gt; in your Python script, so the script can receive the results of the Splunk search and process them.&lt;/P&gt;

&lt;P&gt;Here is an example of a script I use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myresults,dummyresults,settings = splunk.Intersplunk.getOrganizedResults() # getting search results form Splunk
for r in myresults: # loop the results
    for k, v in r.items(): # get key value pairs for each result
        if k == "server": # get key
            section_name = v # set value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will check the results passed by Splunk for a field called &lt;CODE&gt;server&lt;/CODE&gt; and if found it uses its value.&lt;BR /&gt;
At the end of the script it will return the output back to Splunk using this line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; splunk.Intersplunk.outputResults(results) # print the result into Splunk UI
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 20:34:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284390#M3552</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-02-18T20:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass values (dynamically derived from event) to a Python script as command line arguments?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284391#M3553</link>
      <description>&lt;P&gt;@MuS I used the same &lt;BR /&gt;
results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults()&lt;BR /&gt;
 to grab the events from search results  but it doesnt work ?&lt;/P&gt;

&lt;P&gt;any ideas ?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 01:10:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-pass-values-dynamically-derived-from-event-to-a-Python/m-p/284391#M3553</guid>
      <dc:creator>aab5272</dc:creator>
      <dc:date>2017-07-14T01:10:41Z</dc:date>
    </item>
  </channel>
</rss>

