<?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 Scripted Input: Python-&amp;gt;Bat- File-&amp;gt;JAR File in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Scripted-Input-Python-gt-Bat-File-gt-JAR-File/m-p/394501#M6672</link>
    <description>&lt;P&gt;1) I have a JAR file that produces data I wish to index.&lt;BR /&gt;
2) I have a BAT file that calls that JAR file,&lt;BR /&gt;
3) I have a py file that calls the BAT file.&lt;/P&gt;

&lt;P&gt;I am able to execute all 3 components from the Windows cmdline separately and receive the expected results on stdout.&lt;/P&gt;

&lt;P&gt;I have configured a Script Data Input that calls the py file every 60 seconds&lt;BR /&gt;
[script://$SPLUNK_HOME/etc/apps/my-app/bin/my-script.py]&lt;BR /&gt;
disabled = 0&lt;BR /&gt;
index = my_index&lt;BR /&gt;
interval = 60&lt;BR /&gt;
sourcetype = my_ds&lt;/P&gt;

&lt;P&gt;I have raised LOg Level on ExecProcessor to DEBUG&lt;/P&gt;

&lt;P&gt;All I can get from the logs is an entry every 60 seconds like:&lt;BR /&gt;
05-09-2018 11:46:27.483 -0400 DEBUG ExecProcessor - cmd='python "C:\Program Files\Splunk\etc\apps\my-app\bin\my-script.py"' Not added to run queue&lt;/P&gt;

&lt;P&gt;If I replace the call to the BAT file in the py file with a print command - that output does come into the index, but as soon as I replace it with a call to the bat file, it again fails in obscurity.&lt;/P&gt;

&lt;P&gt;Here is an excerpt of the py file after the import statements:&lt;BR /&gt;
script_dirpath = os.path.dirname(os.path.join(os.getcwd(), &lt;STRONG&gt;file&lt;/STRONG&gt;))&lt;BR /&gt;
script_filepath = os.path.join(script_dirpath, 'my-script.bat')&lt;BR /&gt;
print subprocess.call(script_filepath)&lt;/P&gt;

&lt;P&gt;I have also tried configuring the input to call the BAT file directly, but get the same result.&lt;/P&gt;

&lt;P&gt;Can anybody point to an example where this method works, or to a way to increase logging level on nother component so I can see why it is failing?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:30:08 GMT</pubDate>
    <dc:creator>jeffreynmoss</dc:creator>
    <dc:date>2020-09-29T19:30:08Z</dc:date>
    <item>
      <title>Scripted Input: Python-&gt;Bat- File-&gt;JAR File</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Scripted-Input-Python-gt-Bat-File-gt-JAR-File/m-p/394501#M6672</link>
      <description>&lt;P&gt;1) I have a JAR file that produces data I wish to index.&lt;BR /&gt;
2) I have a BAT file that calls that JAR file,&lt;BR /&gt;
3) I have a py file that calls the BAT file.&lt;/P&gt;

&lt;P&gt;I am able to execute all 3 components from the Windows cmdline separately and receive the expected results on stdout.&lt;/P&gt;

&lt;P&gt;I have configured a Script Data Input that calls the py file every 60 seconds&lt;BR /&gt;
[script://$SPLUNK_HOME/etc/apps/my-app/bin/my-script.py]&lt;BR /&gt;
disabled = 0&lt;BR /&gt;
index = my_index&lt;BR /&gt;
interval = 60&lt;BR /&gt;
sourcetype = my_ds&lt;/P&gt;

&lt;P&gt;I have raised LOg Level on ExecProcessor to DEBUG&lt;/P&gt;

&lt;P&gt;All I can get from the logs is an entry every 60 seconds like:&lt;BR /&gt;
05-09-2018 11:46:27.483 -0400 DEBUG ExecProcessor - cmd='python "C:\Program Files\Splunk\etc\apps\my-app\bin\my-script.py"' Not added to run queue&lt;/P&gt;

&lt;P&gt;If I replace the call to the BAT file in the py file with a print command - that output does come into the index, but as soon as I replace it with a call to the bat file, it again fails in obscurity.&lt;/P&gt;

&lt;P&gt;Here is an excerpt of the py file after the import statements:&lt;BR /&gt;
script_dirpath = os.path.dirname(os.path.join(os.getcwd(), &lt;STRONG&gt;file&lt;/STRONG&gt;))&lt;BR /&gt;
script_filepath = os.path.join(script_dirpath, 'my-script.bat')&lt;BR /&gt;
print subprocess.call(script_filepath)&lt;/P&gt;

&lt;P&gt;I have also tried configuring the input to call the BAT file directly, but get the same result.&lt;/P&gt;

&lt;P&gt;Can anybody point to an example where this method works, or to a way to increase logging level on nother component so I can see why it is failing?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:30:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Scripted-Input-Python-gt-Bat-File-gt-JAR-File/m-p/394501#M6672</guid>
      <dc:creator>jeffreynmoss</dc:creator>
      <dc:date>2020-09-29T19:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Scripted Input: Python-&gt;Bat- File-&gt;JAR File</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Scripted-Input-Python-gt-Bat-File-gt-JAR-File/m-p/394502#M6673</link>
      <description>&lt;P&gt;Found that I had tested the JAR file under my Windows user name, but when run from Splunk, it is run under SYSTEM user. Further, I had code that used the USER name to construct a path to configuration data, which when run under Splunk did not exist for the SYSTEM user.&lt;/P&gt;

&lt;P&gt;So changing the code to look for configuration data relative to the current working directory solved the problem. &lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 20:14:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Scripted-Input-Python-gt-Bat-File-gt-JAR-File/m-p/394502#M6673</guid>
      <dc:creator>jeffreynmoss</dc:creator>
      <dc:date>2018-05-10T20:14:19Z</dc:date>
    </item>
  </channel>
</rss>

