Splunk Dev

Python Script reading another file

mrlandis3
Path Finder

I am using a Python scripted input that needs to read from a text file an encoded username and password. The script then writes the results from an API call to a JSON file. So the pseudocode looks like this:

with open('key.txt', 'r') as file:
    set username and password

data = API call

with open('json', 'w') as file2:
    write data

My script is throwing an error saying that the key.txt file does not exist when it is definitely in the same directory. Are there any permission issues that could be causing this?

Labels (1)
0 Karma
1 Solution

mrlandis3
Path Finder

Issue has been fixed, the scripts required the absolute file path since the python file is not running from the context of the folder it is stored in.

View solution in original post

0 Karma

mrlandis3
Path Finder

Issue has been fixed, the scripts required the absolute file path since the python file is not running from the context of the folder it is stored in.

0 Karma
Get Updates on the Splunk Community!

Database Performance Sidebar Panel Now on APM Database Query Performance & Service ...

We’ve streamlined the troubleshooting experience for database-related service issues by adding a database ...

IM Landing Page Filter - Now Available

We’ve added the capability for you to filter across the summary details on the main Infrastructure Monitoring ...

Dynamic Links from Alerts to IM Navigators - New in Observability Cloud

Splunk continues to improve the troubleshooting experience in Observability Cloud with this latest enhancement ...