<?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 run batch file in splunk ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143090#M29242</link>
    <description>&lt;P&gt;when i double click on bat file its running.&lt;/P&gt;

&lt;P&gt;But when i use cmd prompt to run :&lt;/P&gt;

&lt;P&gt;c:\Program Files\Splunk\bin&amp;gt;splunk cmd test1.bat&lt;/P&gt;

&lt;P&gt;its not showing anything.. my doubt is if the script is in scripts how will it run from bin??&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jun 2015 02:36:58 GMT</pubDate>
    <dc:creator>shannu1241</dc:creator>
    <dc:date>2015-06-05T02:36:58Z</dc:date>
    <item>
      <title>How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143079#M29231</link>
      <description>&lt;P&gt;I have a batch file named "testbatch.bat" and its content are as follows:&lt;/P&gt;

&lt;P&gt;@echo off&lt;BR /&gt;
@echo This is a test&amp;gt; test.txt&lt;BR /&gt;
@echo 123&amp;gt;&amp;gt; test.txt&lt;BR /&gt;
@echo 245.67&amp;gt;&amp;gt; test.txt&lt;/P&gt;

&lt;P&gt;I have kept this under $SPLUNK_HOME\etc\system\bin&lt;/P&gt;

&lt;P&gt;and changed the inputs.conf file to :&lt;/P&gt;

&lt;P&gt;[script://$SPLUNK_HOME\etc\system\bin\testbatch.bat] &lt;BR /&gt;
disabled = 0 &lt;BR /&gt;
index = main&lt;/P&gt;

&lt;P&gt;[monitor://$SPLUNK_HOME\etc\system\bin\test.txt]&lt;BR /&gt;
disabled = 0 &lt;BR /&gt;
index = main&lt;/P&gt;

&lt;P&gt;But i dont see any data being indexed to main. I also cannot see "test.txt" being created under \etc\system\bin i.e batch file is not being executed,&lt;/P&gt;

&lt;P&gt;Can the splunk experts help me out !!! My requirement is to run a batch file every 1 minute and index the output to main indexer.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 23:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143079#M29231</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-04T23:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143080#M29232</link>
      <description>&lt;P&gt;Your &lt;CODE&gt;inputs.conf&lt;/CODE&gt; is missing an interval to run the script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;interval = [&amp;lt;number&amp;gt;|&amp;lt;cron schedule&amp;gt;]
* How often to execute the specified command (in seconds), or a valid cron schedule. 
* NOTE: when a cron schedule is specified, the script is not executed on start-up.
* If specified as a number, may have a fractional component; e.g., 3.14
* Splunk's cron implementation does not currently support names of months/days.
* Defaults to 60.0 seconds.
* The special value 0 will force this scripted input to be executed non-stop; that is, as soon as script exits, we shall re-start it.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jun 2015 01:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143080#M29232</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T01:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143081#M29233</link>
      <description>&lt;P&gt;i added and tried with interval = 60 but didnt work.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 01:52:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143081#M29233</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-05T01:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143082#M29234</link>
      <description>&lt;P&gt;Also, take a look at &lt;CODE&gt;$SPLUNK_HOME\var\log\splunk\splunkd.log&lt;/CODE&gt;, it should tell you if the script is executing or not. Also run &lt;CODE&gt;$SPLUNK_HOME\bin\splunk cmd btool inputs list&lt;/CODE&gt; to see if you can find your script listed, as this will indicate if the configuration is correct.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 01:56:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143082#M29234</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T01:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143083#M29235</link>
      <description>&lt;P&gt;Another hint, place your script into &lt;CODE&gt;$SPLUNK_HOME/bin/scripts&lt;/CODE&gt; and try to run it like &lt;CODE&gt;$SPLUNK_HOME/bin/splunk cmd yourscript.bat&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:01:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143083#M29235</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T02:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143084#M29236</link>
      <description>&lt;P&gt;I have placed my script under $SPLUNK_HOME/bin/scripts but how to run it..? Can you elaborate pls.&lt;/P&gt;

&lt;P&gt;Do i need to change anything in inputs.conf file?? &lt;/P&gt;

&lt;P&gt;Pls help me.. i am new to splunk..&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:12:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143084#M29236</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-05T02:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143085#M29237</link>
      <description>&lt;P&gt;cd $SPLUNK_HOME/bin/scripts&lt;BR /&gt;
$SPLUNK_HOME/bin/splunk cmd yourscript.bat&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:10:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143085#M29237</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-09-28T20:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143086#M29238</link>
      <description>&lt;P&gt;i need that script to be run every 1 minutes automatically, how can i achieve that?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:15:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143086#M29238</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-05T02:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143087#M29239</link>
      <description>&lt;P&gt;like I said before, add &lt;CODE&gt;interval = 60&lt;/CODE&gt; to your inputs.conf or configure it in the UI &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/Data/Scripts"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/Data/Scripts&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:18:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143087#M29239</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T02:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143088#M29240</link>
      <description>&lt;P&gt;tried .. but same result.. &lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143088#M29240</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-05T02:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143089#M29241</link>
      <description>&lt;P&gt;is your script running at all if you do this &lt;CODE&gt;$SPLUNK_HOME/bin/splunk cmd yourscript.bat&lt;/CODE&gt; in the directory where the script is? I must admit, I have no Windows Splunk handy and cannot test anything.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143089#M29241</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T02:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143090#M29242</link>
      <description>&lt;P&gt;when i double click on bat file its running.&lt;/P&gt;

&lt;P&gt;But when i use cmd prompt to run :&lt;/P&gt;

&lt;P&gt;c:\Program Files\Splunk\bin&amp;gt;splunk cmd test1.bat&lt;/P&gt;

&lt;P&gt;its not showing anything.. my doubt is if the script is in scripts how will it run from bin??&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 02:36:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143090#M29242</guid>
      <dc:creator>shannu1241</dc:creator>
      <dc:date>2015-06-05T02:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to run batch file in splunk ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143091#M29243</link>
      <description>&lt;P&gt;Hi shaunnu1241,&lt;/P&gt;

&lt;P&gt;I tested it with this script in &lt;CODE&gt;$SPLUNK_HOME\bin\scripts&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;foo.bat
    echo This is a test &amp;gt; "C:\Program Files\Splunk\var\log\splunk\test.txt"
    echo 123 &amp;gt;&amp;gt; "C:\Program Files\Splunk\var\log\splunk\test.txt"
    echo 245.67 &amp;gt;&amp;gt; "C:\Program Files\Splunk\var\log\splunk\test.txt"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it works by running it like &lt;CODE&gt;C:\Program Files\Splunk\bin&amp;gt;splunk.exe cmd scripts\foo.bat&lt;/CODE&gt; the result in &lt;CODE&gt;"C:\Program Files\Splunk\var\log\splunk\test.txt"&lt;/CODE&gt; looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;This is a test 
123 
245.67 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using it as scripted input running each 60 seconds works as well if using this &lt;CODE&gt;inputs.conf&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://$SPLUNK_HOME\bin\scripts\foo.bat]
disabled = false
interval = 10
sourcetype = foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 03:18:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-run-batch-file-in-splunk/m-p/143091#M29243</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-05T03:18:51Z</dc:date>
    </item>
  </channel>
</rss>

