Getting Data In

Executing python script as an alert action on windows

AKG1_old1
Builder

Hi,

I have to run python script as an alert action. My Splunk is on windows.

I tried my script running like this and its working. Its very basic hello world script.

C:\Program Files\Splunk\bin>splunk cmd python hello_world.py
This message will be displayed on the screen.

commands.conf  

[hello_world]
filename = hello_world.py

I have placed commands.conf in C:\Program Files\Splunk\etc\apps\search\local and C:\Program Files\Splunk\etc\system\local

when I am trying running this script from command line  its not working.
| script python hello_world 
OR
| script hello_world

Error Message: 
Error in 'script' command: Cannot find program 'hello_world' or script 'hello_world'.

Not sure why its not be able to find the script. I have placed it to multiple location.
$SPLUNK_HOME$\etc\apps\search\bin\scripts\hello_world.py
$SPLUNK_HOME$\bin\hello_world.py   (from command line it take this script)

My ultimate goal is to run this script as an alert action. but I dont think there is option to run python script. I have option as run a script but seems like that is only for shell script.

Thanks

 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...