Splunk Dev

Splunk custom command ERROR ValueError: I/O operation on closed file

Bhupal
Engager

 

 

I've a custom command worked well with 8.2 and failing in 9.3 with the following error. Tried with both protocol version 1 and 2, i.e Intersplunk and Splunk SDK ways. 

Sharing of your experience and possible fix for this error would be much appreciated.  thank you in advacne.

03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':  Traceback (most recent call last):
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':    File "/opt/splunk/etc/apps/botcop/bin/nndetailscmd.py", line 11, in <module>
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':      results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults()
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':    File "/opt/splunk/lib/python3.9/site-packages/splunk/Intersplunk.py", line 359, in getOrganizedResults
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':      results = readResults(input_str, settings)
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':    File "/opt/splunk/lib/python3.9/site-packages/splunk/Intersplunk.py", line 275, in readResults
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':      input_buf = TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
03-15-2026 17:31:06.388 ERROR ScriptRunner [3954753 phase_1] - stderr from '/opt/splunk/bin/python3.9 /opt/splunk/etc/apps/botcop/bin/nndetailscmd.py':  ValueError: I/O operation on closed file

 

Labels (1)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

I'd take a guess that it's an issue with a python version incompatibility. 9.3 uses python 3.9 by default whereas earlier 9.x used 3.7 I think.

With 8.2 you probably could have still gotten away with python 2 so if your command used this it shouldn't work properly with Splunk 9.3.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...