Are you using Python in Windows? That's not how you use os.environ in Python. You don't specify the environment variable with a leading '$'.
[shaskell@docker ~]$ export FOO=la
[shaskell@docker ~]$ python
Python 2.7.5 (default, Jun 24 2015, 00:41:19)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print(os.environ['FOO']);
la
You'd only access the argument like $SPLUNK_ARG_0 if it were from a shell script in Unix or %SPLUNK_ARG_0% if it were from a batch file in Windows.
You can also access the arguments positionally in Python. Given the following script:
#!/usr/bin/env python
import sys
print(sys.argv[0])
print(sys.argv[1])
[shaskell@docker ~]$ ./foo.py arg1
./foo.py
arg1
So sys.argv[0] is $SPLUNK_ARG_0 (name of the script) and so on. Also note that the 9th argument is the Splunk session key in case you want to interact with the REST API from your script.
... View more