我正在尝试通过python脚本提供“sudo su - appluser”帐户的密码
import pexpect
chld = pexpect.spawn('sudo su - appluser')
chld.expect('[sudo] password for rajesh:')
chld.sendline('XXX')
#print chld.before
但是我收到了这个错误
Traceback (most recent call last):
File "test3.py", line 3, in <module>
child = pexpect.spawn('sudo su - appluser')
File "/users/rajesh/pexpect/__init__.py", line 511, in __init__
self._spawn(command, args)
File "/users/rajesh/pexpect/__init__.py", line 616, in _spawn
'executable: %s.' % self.command)
pexpect.ExceptionPexpect: The command was not found or was not executable: sudo.
请你检查这个并在这里纠正我
答案 0 :(得分:0)
尝试使用sudo命令的绝对路径(/ usr / bin / sudo)。