Hello,
If the trigger of the execution of the script is based on search results, then you can use Splunk alerts to achieve this.
After you search is completed, click on Save As -> Alert -> Add Actions -> Run a script -> type script name.
Location of script:
$SPLUNK_HOME/bin/scripts
Regards
... View more