Getting Data In

Running external script from search

echalex
Builder

Hi,

I'm trying to generate events through an external script from the search, using the script command. Splunk says the command does not exist in commands.conf. However, the documentation for the script command doesn't say that the script needs to exist in commands.conf. Is this just a simple omission, or am I doing something wrong?

This is what I'm trying to do:

| script perl foo
Tags (2)
0 Karma
1 Solution

MHibbin
Influencer

I've not used the "script" command before, but I do use external scripts as custom commands. This involves setting up the "commands.conf" file.

Your script should live within the "bin" directory of your app, e.g. $SPLUNK_HOME/etc/apps/<appName>/bin/, you should then add something like the following to the app's "local" directory...

[exampleCommand]
filename = script.pl
type = perl

You can then call the script in Splunk like the following assuming you have 2 arguments.

*| exampleCommand arg1 arg2

View solution in original post

brettcarroll
Explorer

According to
the documentation for the script command you can't use script like you are thinking.

script calls an external python program that can modify or generate search results. Scripts must be declared in the commands.conf file and be located in the $SPLUNK_HOME/etc/apps//bin/ directory. The script is executed using $SPLUNK_HOME/bin/python

0 Karma

MHibbin
Influencer

I've not used the "script" command before, but I do use external scripts as custom commands. This involves setting up the "commands.conf" file.

Your script should live within the "bin" directory of your app, e.g. $SPLUNK_HOME/etc/apps/<appName>/bin/, you should then add something like the following to the app's "local" directory...

[exampleCommand]
filename = script.pl
type = perl

You can then call the script in Splunk like the following assuming you have 2 arguments.

*| exampleCommand arg1 arg2

MHibbin
Influencer

Sorry I couldn't help on the command itself, but good job on getting a solution working.

0 Karma

echalex
Builder

How the script command is supposed to be used is still a bit unclear to me, but editing commands.conf certainly works.

0 Karma

echalex
Builder

Hi,
Yes, this is pretty much what is described in the documentation about custom commands in the documentation. The documentation for the script command led me to believe you can avoid editing commands.conf.

0 Karma
Get Updates on the Splunk Community!

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

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 ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...