<?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 How to trigger script with arguments from Splunk search? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321221#M59908</link>
    <description>&lt;P&gt;I was able to make splunk send alert to my &lt;CODE&gt;abc_pythonscript&lt;/CODE&gt;  correctly after configuring commands.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval myfield="some_raw_message" | table myfield| script abc_pythonscript myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I look into the arguments coming to my script, is &lt;CODE&gt;myfield&lt;/CODE&gt;  rather than the value within it. I was expecting the value of "&lt;EM&gt;some_raw_message&lt;/EM&gt;" to be passed to my script.&lt;/P&gt;

&lt;P&gt;Is it a mistake I'm doing or any better ways to do this?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 13:00:14 GMT</pubDate>
    <dc:creator>koshyk</dc:creator>
    <dc:date>2020-09-29T13:00:14Z</dc:date>
    <item>
      <title>How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321221#M59908</link>
      <description>&lt;P&gt;I was able to make splunk send alert to my &lt;CODE&gt;abc_pythonscript&lt;/CODE&gt;  correctly after configuring commands.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval myfield="some_raw_message" | table myfield| script abc_pythonscript myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I look into the arguments coming to my script, is &lt;CODE&gt;myfield&lt;/CODE&gt;  rather than the value within it. I was expecting the value of "&lt;EM&gt;some_raw_message&lt;/EM&gt;" to be passed to my script.&lt;/P&gt;

&lt;P&gt;Is it a mistake I'm doing or any better ways to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321221#M59908</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2020-09-29T13:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321222#M59909</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults | eval myfield="some_raw_message" |map search="| makeresults | abc_pythonscript $myfield$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 17:43:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321222#M59909</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-21T17:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321223#M59910</link>
      <description>&lt;P&gt;great thanks. worked like a charm&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 12:23:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321223#M59910</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-02-22T12:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321224#M59911</link>
      <description>&lt;P&gt;Hi Koshyk, &lt;/P&gt;

&lt;P&gt;I have a similar requirement. Would be helpful if you could share the script how you are passing the splunk alert values into a python script. &lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 13:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321224#M59911</guid>
      <dc:creator>vadivel_parames</dc:creator>
      <dc:date>2019-04-04T13:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321225#M59912</link>
      <description>&lt;P&gt;hi mate&lt;BR /&gt;
1. create a python script (say my_python_script)&lt;BR /&gt;
2. Ensure it has permissions to read from the app context&lt;BR /&gt;
3. Run your base query and output results as you wish for your python script&lt;BR /&gt;
4. and as answer given above pass those into a "map" command&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321225#M59912</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2020-09-30T00:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321226#M59913</link>
      <description>&lt;P&gt;You should really post a new question, but perhaps my (unaccepted) answer here helps?&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/41949/passing-search-results-to-external-python-script.html"&gt;https://answers.splunk.com/answers/41949/passing-search-results-to-external-python-script.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 15:00:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321226#M59913</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-07T15:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321227#M59914</link>
      <description>&lt;P&gt;Could you please share abc_pythonscript  ?&lt;BR /&gt;
See my answer below (&lt;STRONG&gt;worked&lt;/STRONG&gt;).&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 14:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321227#M59914</guid>
      <dc:creator>highsplunker</dc:creator>
      <dc:date>2019-06-03T14:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321228#M59915</link>
      <description>&lt;P&gt;This worked for me:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;step 1.&lt;/STRONG&gt; in search box of &lt;STRONG&gt;web interface&lt;/STRONG&gt;&lt;BR /&gt;
| makeresults | jonsnow dest="bbb", source="bla-bla-bla"&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;step 2.&lt;/STRONG&gt; for "jonsnow" custom command to work&lt;BR /&gt;
write this in &lt;STRONG&gt;commands.conf&lt;/STRONG&gt;&lt;BR /&gt;
[jonsnow]&lt;BR /&gt;
filename = jonsnow.py&lt;/P&gt;

&lt;P&gt;and this to &lt;STRONG&gt;local.meta&lt;/STRONG&gt; of the same Splunk app&lt;/P&gt;

&lt;P&gt;[commands/jonsnow]&lt;BR /&gt;
access = read : [ * ], write : [ admin, power ]&lt;BR /&gt;
export = system&lt;BR /&gt;
owner = myusername&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;step 3.&lt;/STRONG&gt; the script itself (&lt;STRONG&gt;jonsnow.py&lt;/STRONG&gt;)&lt;BR /&gt;
import splunk.Intersplunk&lt;BR /&gt;
import subprocess&lt;BR /&gt;
keywords, argvals = splunk.Intersplunk.getKeywordsAndOptions()&lt;BR /&gt;
xxx = argvals['xxx']&lt;BR /&gt;
yyy = argvals['yyy']&lt;BR /&gt;
subprocess.call(["sh", "./jonsnow.sh", xxx, yyy])&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 14:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321228#M59915</guid>
      <dc:creator>highsplunker</dc:creator>
      <dc:date>2019-06-10T14:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to trigger script with arguments from Splunk search?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321229#M59916</link>
      <description>&lt;P&gt;&lt;STRONG&gt;OK, worked too, thanks.&lt;/STRONG&gt;&lt;BR /&gt;
| makeresults | eval myfield="some_raw_message" |map search="| makeresults | abc_pythonscript $myfield$"&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-trigger-script-with-arguments-from-Splunk-search/m-p/321229#M59916</guid>
      <dc:creator>highsplunker</dc:creator>
      <dc:date>2020-09-30T00:54:20Z</dc:date>
    </item>
  </channel>
</rss>

