<?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 execute a py or sh by interface of Splunk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-execute-a-py-or-sh-by-interface-of-Splunk/m-p/196167#M98680</link>
    <description>&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/25658/whats-the-point-of-custom-python-scripts.html"&gt;http://answers.splunk.com/answers/25658/whats-the-point-of-custom-python-scripts.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This is what I did&lt;BR /&gt;
Put my custom python script in this folder&lt;BR /&gt;
/var/sky/splunk/etc/system/bin&lt;/P&gt;

&lt;P&gt;import csv&lt;BR /&gt;
import sys&lt;BR /&gt;
import splunk.Intersplunk&lt;BR /&gt;
import string&lt;BR /&gt;
(isgetinfo, sys.argv) = splunk.Intersplunk.isGetInfo(sys.argv)&lt;BR /&gt;
if len(sys.argv) &amp;lt; 2:&lt;BR /&gt;
splunk.Intersplunk.parseError("No arguments provided to custom script")&lt;/P&gt;

&lt;P&gt;results = splunk.Intersplunk.readResults(None, None, True)&lt;BR /&gt;
splunk.Intersplunk.outputResults(results)&lt;/P&gt;

&lt;P&gt;Modify commands.conf file in below folder&lt;BR /&gt;
/var/sky/splunk/etc/system/local&lt;/P&gt;

&lt;H1&gt;defaults for all external commands, exceptions are below in individual stanzas&lt;/H1&gt;

&lt;H1&gt;type of script: 'python', 'perl'&lt;/H1&gt;

&lt;P&gt;TYPE = python&lt;/P&gt;

&lt;H1&gt;default FILENAME would be .py for python, .pl for perl and  otherwise&lt;/H1&gt;

&lt;H1&gt;is command streamable?&lt;/H1&gt;

&lt;P&gt;STREAMING = true&lt;/P&gt;

&lt;H1&gt;maximum data that can be passed to command (0 = no limit)&lt;/H1&gt;

&lt;P&gt;MAXINPUTS = 50000&lt;/P&gt;

&lt;H1&gt;end defaults&lt;/H1&gt;

&lt;P&gt;[customtest]&lt;BR /&gt;
filename = customtest.py&lt;/P&gt;

&lt;P&gt;To reload the setting run this URL in your browser (Just in case, if required)&lt;BR /&gt;
&lt;A href="https://SPLUNK_HOSTNAME:PORT/debug/refresh"&gt;https://SPLUNK_HOSTNAME:PORT/debug/refresh&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And this is how we can use custom command in splunk&lt;BR /&gt;
 | customtest &lt;STRONG&gt;GETINFO&lt;/STRONG&gt; [Inputparameters]&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jul 2015 15:07:01 GMT</pubDate>
    <dc:creator>vinitatsky</dc:creator>
    <dc:date>2015-07-07T15:07:01Z</dc:date>
    <item>
      <title>How to execute a py or sh by interface of Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-execute-a-py-or-sh-by-interface-of-Splunk/m-p/196166#M98679</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I write a xxx.sh in the /splunk/etc/apps/my_apps/bin and by the commande line &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;./xxx.sh &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;to execute the code.&lt;/P&gt;

&lt;P&gt;Could I add a bouton or something else in the interface of my app in Splunk&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/451i8B12A16B41DAD08D/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;to trigger the xxx.sh.&lt;/P&gt;

&lt;P&gt;Thank you very much&lt;BR /&gt;
Hanzhi&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 14:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-execute-a-py-or-sh-by-interface-of-Splunk/m-p/196166#M98679</guid>
      <dc:creator>Lindaiyu</dc:creator>
      <dc:date>2015-07-07T14:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute a py or sh by interface of Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-execute-a-py-or-sh-by-interface-of-Splunk/m-p/196167#M98680</link>
      <description>&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/25658/whats-the-point-of-custom-python-scripts.html"&gt;http://answers.splunk.com/answers/25658/whats-the-point-of-custom-python-scripts.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This is what I did&lt;BR /&gt;
Put my custom python script in this folder&lt;BR /&gt;
/var/sky/splunk/etc/system/bin&lt;/P&gt;

&lt;P&gt;import csv&lt;BR /&gt;
import sys&lt;BR /&gt;
import splunk.Intersplunk&lt;BR /&gt;
import string&lt;BR /&gt;
(isgetinfo, sys.argv) = splunk.Intersplunk.isGetInfo(sys.argv)&lt;BR /&gt;
if len(sys.argv) &amp;lt; 2:&lt;BR /&gt;
splunk.Intersplunk.parseError("No arguments provided to custom script")&lt;/P&gt;

&lt;P&gt;results = splunk.Intersplunk.readResults(None, None, True)&lt;BR /&gt;
splunk.Intersplunk.outputResults(results)&lt;/P&gt;

&lt;P&gt;Modify commands.conf file in below folder&lt;BR /&gt;
/var/sky/splunk/etc/system/local&lt;/P&gt;

&lt;H1&gt;defaults for all external commands, exceptions are below in individual stanzas&lt;/H1&gt;

&lt;H1&gt;type of script: 'python', 'perl'&lt;/H1&gt;

&lt;P&gt;TYPE = python&lt;/P&gt;

&lt;H1&gt;default FILENAME would be .py for python, .pl for perl and  otherwise&lt;/H1&gt;

&lt;H1&gt;is command streamable?&lt;/H1&gt;

&lt;P&gt;STREAMING = true&lt;/P&gt;

&lt;H1&gt;maximum data that can be passed to command (0 = no limit)&lt;/H1&gt;

&lt;P&gt;MAXINPUTS = 50000&lt;/P&gt;

&lt;H1&gt;end defaults&lt;/H1&gt;

&lt;P&gt;[customtest]&lt;BR /&gt;
filename = customtest.py&lt;/P&gt;

&lt;P&gt;To reload the setting run this URL in your browser (Just in case, if required)&lt;BR /&gt;
&lt;A href="https://SPLUNK_HOSTNAME:PORT/debug/refresh"&gt;https://SPLUNK_HOSTNAME:PORT/debug/refresh&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And this is how we can use custom command in splunk&lt;BR /&gt;
 | customtest &lt;STRONG&gt;GETINFO&lt;/STRONG&gt; [Inputparameters]&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 15:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-execute-a-py-or-sh-by-interface-of-Splunk/m-p/196167#M98680</guid>
      <dc:creator>vinitatsky</dc:creator>
      <dc:date>2015-07-07T15:07:01Z</dc:date>
    </item>
  </channel>
</rss>

