Splunk Search

Scripted Input failing, runs fine when run manually

kholleran
Communicator

Hello,

I have a scriped input that is throwing an error:

ERROR ExecProcessor - message from ""MyScript.bat"" python: can't open file 'MyScript.py': [Errno 2] No such file or directory

However, when I log into that server, run the batch file from the command line, it runs just fine. The batch file looks like this:

@echo off "PATH_TO_SPLUNK.EXE\splunk.exe" cmd python MyScript.py

This runs in the etc/apps/myscriptapp/bin

Does anyone know whey the batch file would run just fine when executed from the cmd line and not from within Splunk?

Thanks for any help.

Kevin

0 Karma

kholleran
Communicator

I ended up putting the whole path in the MyScript.py section instead of the relative path.

@echo off "PATH_TO_SPLUNK.EXE\splunk.exe" cmd python "PATH_TO_SCRIPT\MyScript.py"

jrodman
Splunk Employee
Splunk Employee

splunk cmd has special behavior for running executables, (it looks in a particular directory) but python doesn't. Python myscript.py will look in the current directory, wherever that is. I recommend using the environment. For a batch file, %SPLUNK_HOME%\etc\apps\myapp\bin\foo.py

0 Karma

Brian_Osburn
Builder

Doh! I've had that happen too..

0 Karma

Brian_Osburn
Builder

Is $SPLUNK_HOME/var/log/splunk/splunkd.log reporting any errors when it runs?

I think the script needs to be under $SPLUNK_HOME/bin/scripts..

Brian

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...