<?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 run a Shell Script run from a search command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168869#M48163</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to run a shell script from a search command. So I have created a shell script under &lt;CODE&gt;$SPLUNK_HOME/etc/apps/myapp/bin/&lt;/CODE&gt; and a specific commands.conf file with the below content:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MYSCRIPT]
type = shell
file = ./myscript.sh
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running the following command on the search bar:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| script MYSCRIPT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got an error message which is:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The type 'shell' for command 'MYSCRIPT' in commands.conf is invalid.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;As per the doc, if I understand well, we can only use python or perl?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;filename = "string"
    * Name of script file for command.
    * &amp;lt;script-name&amp;gt;.pl for perl.
    * &amp;lt;script-name&amp;gt;.py for python.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for your answer.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Aug 2015 09:37:42 GMT</pubDate>
    <dc:creator>SirHill17</dc:creator>
    <dc:date>2015-08-12T09:37:42Z</dc:date>
    <item>
      <title>How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168869#M48163</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to run a shell script from a search command. So I have created a shell script under &lt;CODE&gt;$SPLUNK_HOME/etc/apps/myapp/bin/&lt;/CODE&gt; and a specific commands.conf file with the below content:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MYSCRIPT]
type = shell
file = ./myscript.sh
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running the following command on the search bar:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| script MYSCRIPT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got an error message which is:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The type 'shell' for command 'MYSCRIPT' in commands.conf is invalid.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;As per the doc, if I understand well, we can only use python or perl?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;filename = "string"
    * Name of script file for command.
    * &amp;lt;script-name&amp;gt;.pl for perl.
    * &amp;lt;script-name&amp;gt;.py for python.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for your answer.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 09:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168869#M48163</guid>
      <dc:creator>SirHill17</dc:creator>
      <dc:date>2015-08-12T09:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168870#M48164</link>
      <description>&lt;P&gt;You need to change &lt;CODE&gt;file = ./myscript.sh&lt;/CODE&gt; to &lt;CODE&gt;filename = ./myscript.sh&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 21:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168870#M48164</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-12T21:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168871#M48165</link>
      <description>&lt;P&gt;Correcting that I still got the same error message.&lt;/P&gt;

&lt;P&gt;Checking the Splunk help:&lt;/P&gt;

&lt;P&gt;| script &lt;BR /&gt;
&lt;EM&gt;Makes calls to external Perl or Python programs&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;So I assume it is not possible to run shell script ? Anyone can confirm ?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 15:39:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168871#M48165</guid>
      <dc:creator>SirHill17</dc:creator>
      <dc:date>2015-08-13T15:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168872#M48166</link>
      <description>&lt;P&gt;The documentation is a bit vague so I am unsure.  I always do perl and that works so you could always create a perl wrapper script to check.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2015 16:17:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168872#M48166</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-13T16:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168873#M48167</link>
      <description>&lt;P&gt;It's finally not possible, I did Perl or Python and it works fine, so no shell. We will manage without &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2015 13:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168873#M48167</guid>
      <dc:creator>SirHill17</dc:creator>
      <dc:date>2015-08-25T13:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168874#M48168</link>
      <description>&lt;P&gt;Please click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 21:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168874#M48168</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-17T21:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a Shell Script run from a search command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168875#M48169</link>
      <description>&lt;P&gt;you can create a python for call to os.system&lt;/P&gt;

&lt;P&gt;shelllauncher.py&lt;BR /&gt;
  import os&lt;BR /&gt;
  os.system('./yourscript.sh')&lt;/P&gt;

&lt;P&gt;commands.conf&lt;/P&gt;

&lt;P&gt;[shelllauncher]&lt;BR /&gt;
  chunked=false&lt;BR /&gt;
  type=python&lt;BR /&gt;
  filename = shelllauncher.py&lt;/P&gt;

&lt;P&gt;yourscript.sh&lt;BR /&gt;
  #!/bin/bash&lt;BR /&gt;
  ps aux&lt;/P&gt;

&lt;P&gt;on splunk search:&lt;BR /&gt;
| shelllauncher | table *&lt;/P&gt;

&lt;P&gt;you might see "ps aux" linux command on results&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 15:42:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-a-Shell-Script-run-from-a-search-command/m-p/168875#M48169</guid>
      <dc:creator>cpm003</dc:creator>
      <dc:date>2019-09-17T15:42:37Z</dc:date>
    </item>
  </channel>
</rss>

