I have written a script from the Python to automate scan. I have used nessus for that and used subprocess module in python. Problem is this it's running from the cli bash, but when I put that script to launch through by cron job. It gives following error
Traceback (most recent call last):
File "/root/nessusscan.py", line 9, in <module>
subprocess.call(['nessus','-q','-x','-T','nessus','127.0.0.1','1241','user','password','ip.txt','res'])
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
The script is
subprocess.call(['nessus','-q','-x','-T','nessus','127.0.0.1','1241','user','password','ip.txt','res'])
Command for cron job
16 14 * * * cd /root/nessus; ./nessusscan.py
The error means that the program is found by subprocess but the user running the "nessusscan.py" does not have permissions to run it.
Check ownership of the nessus file and the permissions on it.
Related
I'm using a program called SPAdes-3.50-Darwin and while running it on a server (one which I do not have root access to), I get the following error even though on my local computer it runs fine:
== Running read error correction tool: /export/home/james/Tools/SPAdes-3.5.0-Darwin/bin/hammer /export/home/james/package/output/pg/assembly_files/NA12877_S1_chr14_105900000-107300000/spades_files/3-49/corrected/configs/config.info
[Errno 13] Permission denied
Traceback (most recent call last):
File "/export/home/james/Tools/SPAdes-3.5.0-Darwin/bin/spades.py", line 586, in main
ext_python_modules_home, log)
File "/export/home/james/Tools/SPAdes-3.5.0-Darwin/share/spades/spades_pipeline/hammer_logic.py", line 128, in run_hammer
support.sys_call(command, log)
File "/export/home/james/Tools/SPAdes-3.5.0-Darwin/share/spades/spades_pipeline/support.py", line 181, in sys_call
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Does this have to do with not having root permission?
I am getting the following error while running gclient runhooks for building chromium.
running '/usr/bin/python src/tools/clang/scripts/update.py --if-needed' in '/media/usrname/!!ChiLL out!!'
Traceback (most recent call last):
File "src/tools/clang/scripts/update.py", line 283, in
sys.exit(main())
File "src/tools/clang/scripts/update.py", line 269, in main
stderr=os.fdopen(os.dup(sys.stdin.fileno())))
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Error: Command /usr/bin/python src/tools/clang/scripts/update.py --if-needed returned non-zero exit status 1 in /media/usrname/!!ChiLL out!!
In order to get permission of the directory "/usr/bin/python src/tools/clang/scripts" I tried chown and chmod but it returned the same error.
I think the python scripts in scripts directory are trying to modify some other files or directories .... try to trace what it is trying to do...... You have not specified the OS on which u are working ....... see this link https://github.com/aerospike/aerospike-client-python/issues/22
It says Linux Mint 17 is not supported officially.....
Actually the directory was not mounted with execution permission. So I remounted the directory with execution permission using
mount -o exec /dev/sda5 /media/usrname
and it worked fine.
I have a python script. On top of the script "from subprocess import call". If I write "call(["whoami"])" in the script and I execute the Python script from the unix command line it works, my username returns. But if I run a proprietary command with arguments, "call(["mi_xx", "-s", "20141215","-e","20150121","-p",'TX%_XX%',"-f","test","-i","-x","-d"])"
I get the error below. I run the same command directly in unix and it works. I have searched up and down. The python environment in unix is fine.
Error
Traceback (most recent call last):
File "Mixx.py", line 44, in <module>
call(["mi_xx", "-s", "20141215","-e","20150121","-p",'TX%_XX%',"-f","test","-i","-x","-d"])
File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/subprocess.py", line 595, in __init__
errread, errwrite)
File "/bb/util/common/ActivePythonEE_2.6.2_32bit/lib/python2.6/subprocess.py", line 1092, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory"
I am trying to run a nessus scan from cronjob by subprocess python module. ,but from cronjob it's is giving an error. But not giving any error on execution of script from bash?
the cronjob code
01 11 * * * /root/nessusscan.py
and subprocess call in script is
subprocess.call(['nessus','-q','-x','-T','nessus','127.0.0.1','1241','user','password','ip.txt','res'])
from bash it's working fine but from cronjob i am getting following error in mail
Traceback (most recent call last):
File "/root/nessusscan.py", line 9, in <module>
subprocess.call(['nessus','-q','-x','-T','nessus','127.0.0.1','1241','user','password','ip.txt','res'])
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Thnx to evry one i am answering my own question for other people who will vist this thread. So that they can also get out of this error. In my case error got solved by giving the path of nessus which is "/opt/nessus/bin/nessus"
replaced nessus with "/opt/nessus/bin/nessus"
cronjob was not able to get the path of nessus command.It's working now.
I am trying to execute the following code in Python
import os,subprocess
from glob import glob
path = "/Users/armed/private_SDKs"
os.chdir(path)
for file in glob("*.framework"):
command = ['class-dump' , '-H' , file , '-o' , '~', '/Users/armed/Desktop/Headers/']
subprocess.call(command)
On executing this script i get the following error :-
Traceback (most recent call last):
File "<pyshell#52>", line 3, in <module>
subprocess.call(command)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Any help is much appreciated !
Check permissions of the class-dump command. chmod +x class-dump if it's not executable. Here are the docs on chmod.
You might also need to specify the absolute path to class-dump if it's not on your path.
Also, try:
print " ".join(command)
and see if you can run it by pasting the results into a shell.