Splunk Dev

Why is the Python script not able to read network drives when running as scripted inputs?

arjitgoswami
Explorer

Hi All,

I have written a python script which merely reads the file from the network drive. When I am running this python script manually, the script is running fine & python script is reading the data from the network drive. But when I am using this script as a scripted input (I have placed in script in : $SPLUNK_HOME$/bin/scripts & have updated inputs.conf in the "local" folder), the script throws the following error :

No such files or directory : 'G:\foo\bar\log file'.

Please note that I am running Splunk on Windows enterprise 2012 R2 server.

Can you please help in this regards?

Thanks and regards,
Arjit.

0 Karma
1 Solution

FrankVl
Ultra Champion

My first guess would be that your user account has permissions to view that drive, while the user Splunk is running as, doesn't? So check the folder permissions and/or test-run the script under the same account Splunk uses to get a more representative result.

Alternatively, looking at the error, there may be too many \ characters, but that doesn't explain why it does work when executed manually.

View solution in original post

0 Karma

FrankVl
Ultra Champion

My first guess would be that your user account has permissions to view that drive, while the user Splunk is running as, doesn't? So check the folder permissions and/or test-run the script under the same account Splunk uses to get a more representative result.

Alternatively, looking at the error, there may be too many \ characters, but that doesn't explain why it does work when executed manually.

0 Karma

arjitgoswami
Explorer

@FrankVI: Hi Frank! splunkd logs only refer to the above error message. It doesn't shows anything. There is another observation here. The os.environ parameters are different for my python program and the python installed within splunk. How can I make them both same?

Thanks for your help.

Kind regards,
Arjit.

0 Karma

FrankVl
Ultra Champion

I'm not an expert on python, so can't help you with that I'm afraid. Have you been able to find the user splunk runs as?

PS: please post comments as comments, not as new answers. I can convert them for you but it is a lot easier if you post them correctly right away 🙂

0 Karma

arjitgoswami
Explorer

@FrankVl: Hi Frank ! ahh I got what you mean. Actually didn't see this. Sure will update in the comment section 🙂

Thanks for your help. What I did was I used the stdout from python (print command) to show the username and it was the hostname. I guess that's the reason why it is not able to access the network drives. Still figuring out alternate way to get this going.

Kind regards,
Arjit Goswami.

0 Karma

arjitgoswami
Explorer

@FrankVl: Hi Frank! Thanks for your response. How can I check whether the Splunk has permission to access that folder?

I am able to access network drive using my credential but I am not sure which ID Splunk uses to access the network drive. I am logged in in Admin mode.

Can you help here?

Thanks and regards,
Arjit Goswami.

0 Karma

FrankVl
Ultra Champion

Assuming it is running as a service: check the properties of the splunkd service.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...