我试图在Paramiko exec_command的帮助下从Python在Unix服务器上运行sesu命令.但是当我运行这个命令exec_command(‘sesu test’)时,我得到了
sh: sesu: not found
当我运行简单的ls命令时,它给我所需的输出.只有使用sesu命令它才能正常工作.
这是我的代码的样子:
import paramiko
host = host
username = username
password = password
port = port
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,port,username,password)
stdin,stdout,stderr=ssh.exec_command('sesu test')
stdin.write('Password')
stdin.flush()
outlines=stdout.readlines()
resp=''.join(outlines)
print(resp)