I am totally confused after many hours of trying to figure this out and I couldn't find any other posts similar enough to my problem. Here's my problem:
I want an alert to call a shell script (myShellScript.sh)
I then want myShellScript.sh to execute a Python script (myPythonScript.py) in the same directory.
myShellScript.sh looks like:
myPythonScript.py looks like:
::python code here::
If I execute the shell script from the terminal it works. If I put in a shell script that doesn't try to run an executable into a Splunk alert message it works, but a sheel script that attempts to execute a command is a no-go. None of the logs (splunkd.log, scheduler.log, python.log) list any problems, the python executable has the proper permissions. Anybody know what's going on?
You're assuming that the script's working directory is the path where it resides - however that's not the case. Scripts execute in the root path "/", so when you try to run "./myPythonScript.py" in the script that's equivalent to attempting to run "/myPythonScript.py".
If you reference your Python script using its full path, or for that matter change your working directory at the start of the shell script, your script will work.