<?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 get my python script to trigger through a Splunk search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118358#M31595</link>
    <description>&lt;P&gt;Check the indentation in the code. If the code is not having the proper indentation, then the code will not compile. Use Python Editor (Python IDE) for editing the python files. Using notepad/textpad will not give you proper indentation.&lt;/P&gt;</description>
    <pubDate>Thu, 21 May 2015 10:54:10 GMT</pubDate>
    <dc:creator>vganjare</dc:creator>
    <dc:date>2015-05-21T10:54:10Z</dc:date>
    <item>
      <title>How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118355#M31592</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;I want to trigger my python script through a splunk search. Below is my code, but i don't know which files i have to change to make it run. I just changed commands.conf file of app's local directory, but still it's showing me error 1.&lt;/P&gt;

&lt;P&gt;Is there any document to explain everything about this? If yes please send me the link.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys,splunk.Intersplunk
results = []

 try:
    results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults()

 ############### YOUR CODE HERE ##############
    import csv

    ifile  = open('/opt/splunk/var/run/splunk/check.csv', "rb")
    reader = csv.reader(ifile)



 ############### DATA MANIPULATION HERE ##############

 except:
    import traceback
    stack =  traceback.format_exc()
    results = splunk.Intersplunk.generateErrorResults("Error : Traceback: " + str(stack))

 splunk.Intersplunk.outputResults( results )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 May 2015 17:42:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118355#M31592</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-05-20T17:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118356#M31593</link>
      <description>&lt;P&gt;What you want to do is to create a custom search command, and here is the applicable documentation:&lt;/P&gt;

&lt;P&gt;Slunk SDK for Python "How to create custom search commands" page: &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEU2"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEU2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Documentation &amp;gt; Splunk Enterprise &amp;gt; Developing Views and Apps for Splunk Web &amp;gt; Custom search commands page: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/AdvancedDev/Searchscripts&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The Python script should reside in your apps &lt;CODE&gt;bin&lt;/CODE&gt; directory, and you should also edit &lt;CODE&gt;default/commands.conf&lt;/CODE&gt; to configure the new command.&lt;/P&gt;

&lt;P&gt;The spec file for &lt;CODE&gt;commands.conf&lt;/CODE&gt; can be found here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/admin/Commandsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/admin/Commandsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2015 20:29:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118356#M31593</guid>
      <dc:creator>asieira</dc:creator>
      <dc:date>2015-05-20T20:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118357#M31594</link>
      <description>&lt;P&gt;What is wrong in above code?&lt;BR /&gt;
why its giving me error code 1?&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 10:46:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118357#M31594</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-05-21T10:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118358#M31595</link>
      <description>&lt;P&gt;Check the indentation in the code. If the code is not having the proper indentation, then the code will not compile. Use Python Editor (Python IDE) for editing the python files. Using notepad/textpad will not give you proper indentation.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 10:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118358#M31595</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-21T10:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118359#M31596</link>
      <description>&lt;P&gt;ya thanks, its working now&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 11:06:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118359#M31596</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-05-21T11:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get my python script to trigger through a Splunk search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118360#M31597</link>
      <description>&lt;P&gt;Pro tip: &lt;A href="https://pypi.python.org/pypi/pep8"&gt;pep8&lt;/A&gt; and &lt;A href="https://pypi.python.org/pypi/autopep8/1.1.1"&gt;autopep8&lt;/A&gt; are your friends.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 20:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-my-python-script-to-trigger-through-a-Splunk-search/m-p/118360#M31597</guid>
      <dc:creator>asieira</dc:creator>
      <dc:date>2015-05-21T20:30:24Z</dc:date>
    </item>
  </channel>
</rss>

