Just declare the field in the class like filename = Option(require=True) and then assign the user input as a variable to a new variable e.g. filename = self.filename sample code: #!/usr/bin/env python
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import \
dispatch, GeneratingCommand, Configuration, Option, validators
@Configuration()
class %(command.title())Command(GeneratingCommand):
filename = Option(require=True)
def generate(self):
filename = self.filename
# Put your event code here
# To connect with Splunk, use the instantiated service object which is created using the server-uri and
# other meta details and can be accessed as shown below
# Example:-
# service = self.service
pass
dispatch(%(command.title())Command, sys.argv, sys.stdin, sys.stdout, __name__)
... View more