【发布时间】:2020-01-10 18:07:54
【问题描述】:
我正在尝试使用 plink.exe 从 Windows 机器远程向 linux 机器发出一些命令,并且它成功执行除了 sudo su -
之外的所有命令事实上,它也会执行 sudo su - 我可以看到 I now superuser 的输出,但此时它会冻结,因此无法执行任何其他命令。
这是我目前使用的:
./plink.exe -ssh -v -pw myPassHere myUser@myHost "hostname;ls -la;sudo su - ; touch test.me"
我还尝试像这样将 sudo su 命令发送到后台:
./plink.exe -ssh -v -pw myPassHere myUser@myHost "hostname;ls -la; sudo su - & touch test.me"
这将执行上述命令,包括 sudo su 但会添加:
logout root
stty: Not a typewriter
stty: Not a typewriter
stty: Not a typewriter
并关闭连接 - 仍然没有执行最后一个 touch 命令
还尝试同时添加 & 和 ;像这样:
./plink.exe -ssh -v -pw myPassHere myUser@myHost "hostname;ls -la;sudo su -&;touch test.me"
这给了我:
ksh: syntax error at line 1 : 'end of file' unexpected
我很确定在发出 sudo su - 命令后,提示符会得到一个结果,这就是它冻结但不知道如何暂停一段时间以允许 sudo su - 命令执行或如何执行的原因避免 shell 期望输出。
【问题讨论】:
标签: plink