Getting Data In

Why is my Windows batch file not being executed from my inputs.conf?

jstockton
New Member

I created an App and in my inputs.conf have it calling a Windows batch file to execute an .exe, but the exe seems that it is not executed. I have tried multiple things based on some of posts I found, and haven't gotten it to work yet.

Here is what I currently have setup:
C:\Program Files\Splunk\etc\apps\LogViewer\bin is where my exe is that I want to run along with my batch file to run my exe.

  call "C:\Program Files\Splunk\etc\apps\LogViewer\bin\LogginDB.exe"

C:\Program Files\Splunk\etc\apps\LogViewer\default\inputs.conf contains

  [script:"C:\Program Files\Splunk\etc\apps\LogViewer\bin\LaunchLogging.bat"]
  disabled = 0 # change to true to start the input, requires restart
  host = SHE-STGSQLEXT1 # enter hostname here
  index = main
  interval = 30      #frequency to run the script

My exe is written to output a text file so i know for sure that it is not running and if I run the batch file manually the output is created.

Any one know what I am doing wrong?

Tags (2)
0 Karma
1 Solution

hazekamp
Builder

I believe the issue is with your "script" stanza in inputs.conf. The correct syntax is "script://". Try:

## inputs.conf
[script://$SPLUNK_HOME\etc\apps\LogViewer\bin\LaunchLogging.bat]

View solution in original post

jstockton
New Member

I was able to resolve it. I think it is a combination of a syntax errors. In my first post I have a couple of lines in my inputs.conf where I have a comment after setting a property:

      disabled = 0 # change to true to start the input, requires restart

I removed those comments and also tried your original suggestion of changing the value of my script path in my script stanza. I now have it set to the value of:

      [script://$SPLUNK_HOME\etc\apps\LogViewer\bin\LaunchLogging.bat]

Thanks for your help.

0 Karma

donwant
Explorer

Do you need a double backslash to indicat that you are not escape charachtering?
I can't type it here as the preview removes the second backslash. but I beleive that that is the problem.....
Hope that helps.

0 Karma

hazekamp
Builder

You do not have to escape slashes in inputs.conf file path specifiers.

0 Karma

jstockton
New Member

One other thing, I put my .bat file in C:\Program Files\Splunk\bin\scripts and added a Data Input to this file and everything is working as I expected.

I'm assuming that $SPLUNK_HOME is a system variable. I checked my system variables and did not see that on so I added it and put the value as C:\Program Files\Splunk. The path to Python is part of my path.

0 Karma

hazekamp
Builder

If it is working in $SPLUNK_HOME\bin\scripts, but not in $SPLUNK_HOME\etc\apps\\bin this could be a file permissions issue.

0 Karma

jstockton
New Member

I updated my script stanza by copying and pasting the line you provided, but it still is not launching.

0 Karma

hazekamp
Builder

I believe the issue is with your "script" stanza in inputs.conf. The correct syntax is "script://". Try:

## inputs.conf
[script://$SPLUNK_HOME\etc\apps\LogViewer\bin\LaunchLogging.bat]
Get Updates on the Splunk Community!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...