Splunk Dev

Python Script: Permission Denied in one of the Methods

morethanyell
Builder

Hi,

I have a working Python script that when ran as whoami=splunk in the same box, works just fine and as expected.

When the script is enabled in the Scripted Inputs with "every 5 min" schedule, one line in my ciode does not work and the python processor logs "Permission Denied" in index=_internal.

This is the line that doesn't work (Line  3)

 

 

 

Line 1.
temp_filename = sess + '.tmp'

Line 2.
wget_result = os.system('wget -O ./' + temp_filename + ' --append-output=' + LOGFILE_DIR_WGET + ' --user ' + svcacct_un + ' --password ' + svcacct_pw +  ' --no-check-certificate ' + _url)

Line 3.
checksum = hashlib.md5(open('./' + temp_filename, "rb").read()).hexdigest();

 

 

 

the Error looks like this

 

 

 

03-29-2021 15:55:17.507 +0100 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/***************" ./b97fcd39-1201-4638-8d41-8ae32168cd70.tmp: Permission denied

 

 

 

Anyone?

 

Labels (2)
0 Karma
1 Solution

morethanyell
Builder

Apparently, the filename / path doesn't exist as 

'./' + temp_filename

When changed with absolute filepath, it worked.

View solution in original post

0 Karma

morethanyell
Builder

Apparently, the filename / path doesn't exist as 

'./' + temp_filename

When changed with absolute filepath, it worked.

0 Karma

Vardhan
Contributor

Hi @morethanyell ,

Try to give the full permissions to the script file and restart. And check the output.

0 Karma

morethanyell
Builder

meaning give 777 to the script itself?

0 Karma

Vardhan
Contributor

yes..

0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...