I have the following script, but it keeps erroring out.
What is the error?
We don't know what's going on, either. What makes you think it's "erroring out" if there are no errors?
You may have to add some debugging code to the script so it tells you more about what is happening.
I will test it again later today and let you know if I then see an error. I know the library I wanted to bring in splunklib did not exist.