我试图通过子进程python模块从cronjob运行nessus扫描。 ,但是从cronjob来看它是错误的。 但是从bash执行脚本时没有出现任何错误?
cronjob代码
01 11 * * * /root/nessusscan.py和脚本中的子进程调用是
subprocess.call(['nessus','-q','-x','-T','nessus','127.0.0.1','1241','user','password','ip.txt','res'])从bash它工作正常,但从cronjob我收到邮件中的跟随错误
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 deniedI 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.pyand 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最满意答案
我想回答一个问题,我会回答我自己的问题。 这样他们也可以摆脱这个错误。 在我的情况下,通过给出nessus的路径"/opt/nessus/bin/nessus"来解决错误
用"/opt/nessus/bin/nessus"代替nessus
cronjob无法获得nessus命令的路径。它现在正在工作。
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.
更多推荐
发布评论