Python sudo的子进程,访问/dev/sda:奇怪的错误:[Errno 2]没有这样的文件或目录
我正在尝试使用以下脚本阅读smart(由nagios用户编写): 我确实允许nagios执行该文件(/etc/sudoers): 我很确定我在子流程中获得了root权限,似乎没有授予对设备的访问权限:Python sudo的子进程,访问/dev/sda:奇怪的错误:[Errno 2]没有这样的文件或目录,python,subprocess,sudo,Python,Subprocess,Sudo,我正在尝试使用以下脚本阅读smart(由nagios用户编写): 我确实允许nagios执行该文件(/etc/sudoers): 我很确定我在子流程中获得了root权限,似乎没有授予对设备的访问权限: nagios@x:/dir$ sudo /git/check_smart/smart_watch.py --device /dev/sda Traceback (most recent call last): File "/git/check_smart/smart_watch.py", l
nagios@x:/dir$ sudo /git/check_smart/smart_watch.py --device /dev/sda
Traceback (most recent call last):
File "/git/check_smart/smart_watch.py", line 48, in <module>
main(args.logfile, args.device)
File "/git/check_smart/smart_watch.py", line 18, in main
code = check_smart(device)
File "/git/check_smart/smart_watch.py", line 10, in check_smart
return subprocess.call(args)
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 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ ls -lahtr /dev/sda
brw-rw---- 1 root disk 8, 0 cze 13 14:55 /dev/sda
nagios@x:/dir$sudo/git/check_smart/smart_watch.py--device/dev/sda
回溯(最近一次呼叫最后一次):
文件“/git/check\u smart/smart\u watch.py”,第48行,in
main(args.logfile,args.device)
文件“/git/check\u smart/smart\u watch.py”,第18行,主目录
代码=检查智能(设备)
文件“/git/check\u smart/smart\u watch.py”,第10行,check\u smart
返回子流程调用(args)
文件“/usr/lib/python2.7/subprocess.py”,第493行,在调用中
返回Popen(*popenargs,**kwargs)。等待()
文件“/usr/lib/python2.7/subprocess.py”,第679行,在__
错误读取,错误写入)
文件“/usr/lib/python2.7/subprocess.py”,第1259行,在执行子进程中
引发子对象异常
OSError:[Errno 2]没有这样的文件或目录
$ls-lahtr/dev/sda
brw rw----1根磁盘8,0 cze 13 14:55/dev/sda
命令以root用户身份完美运行
知道为什么“没有这样的文件”错误吗?
我确实希望权限被拒绝,但是/no file/没有找到它
命令找不到smartclt,已更改为:
/usr/sbin/smartctl找到了它
命令找不到smartclt,已更改为:
/usr/sbin/smartctl向上向下投票按钮旁边的小复选标记向上向下投票按钮旁边的小复选标记
nagios@x:/dir$ sudo /git/check_smart/smart_watch.py --device /dev/sda
Traceback (most recent call last):
File "/git/check_smart/smart_watch.py", line 48, in <module>
main(args.logfile, args.device)
File "/git/check_smart/smart_watch.py", line 18, in main
code = check_smart(device)
File "/git/check_smart/smart_watch.py", line 10, in check_smart
return subprocess.call(args)
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 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ ls -lahtr /dev/sda
brw-rw---- 1 root disk 8, 0 cze 13 14:55 /dev/sda