Splunk Search

how can I set $SPLUNK_HOME remotely?

asimagu
Builder

Hi guys

I am trying to deploy an app that contains a scripts that uses the variable $SPLUNK_HOME
the issue comes when $SPLUNK_HOME is different on several servers, or even the variable has not been set at all.

is there any way of including the setting of a variable in a script?

any other approaches would also be appreciated

thanks

0 Karma
1 Solution

asimagu
Builder

I think I coded myself something that works for me
By including this in the beginning of my script, it does the magic I expect it to do

SPLUNK_HOME=pwd | sed -n 's/\(.*splunk\).*/\1/p'

View solution in original post

sumangala
Path Finder

$SPLUNK_HOME is splunk environment variable. You can see this /opt/splunk/bin/splunk envvars.
In python script u can get value:
import os
SPLUNK_HOME = os.environ["SPLUNK_HOME"]

0 Karma

asimagu
Builder

I think I coded myself something that works for me
By including this in the beginning of my script, it does the magic I expect it to do

SPLUNK_HOME=pwd | sed -n 's/\(.*splunk\).*/\1/p'

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...