Splunk Dev

How to use isGetInfo and getKeywordsAndOptions at the same time?

Lowell
Super Champion

What's the recommended way to use both splunk.Intersplunk.getKeywordsAndOptions and splunk.Intersplunk.isGetInfo within a python search command?

I would like to use both of these features at the same time, but there doesn't seem to be an obvious way to do this.

(isgetinfo, args) = splunk.Intersplunk.isGetInfo(sys.argv)
...
args, kwargs = splunk.Intersplunk.getKeywordsAndOptions()

This ends up with either __GETINFO__ or __EXECUTE__ as the first value in args.

Stephen_Sorkin
Splunk Employee
Splunk Employee

The idiom in diff.py and trendline.py that we ship with is to call isGetInfo very early on in execution, like:

(isgetinfo, sys.argv) = splunk.Intersplunk.isGetInfo(sys.argv)

Note that this may not work on Windows where getKeywordsAndOptions uses a source other than sys.argv.

Lowell
Super Champion

I guess that would work, unless you are running windows, which doesn't seem like there is a solution to that (short of building your own getKeywordsAndOptions function) It seems odd to me that isGetInfo() requires "args" to be passed in, and then getKeywordsAndOptions() doesn't allow you to specify the "args".

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