微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python – 使用ssh时在bash中缺少’read’提示符?

请告诉我,我遗漏了一些非常明显的东西:

$cat ~/bashplay/f
#!/bin/bash
read -p 'RDY> ' x
echo $x

$~/bashplay/f
RDY> direct execution
direct execution

$ssh somehost ~/bashplay/f
indirect via ssh
indirect via ssh

请注意缺少的“RDY>”使用ssh时提示.使用“readline”包时,我在python中看到了同样的东西.谁知道为什么?

解决方法:

来自man bash:

-p prompt
display prompt on standard error, without a trailing new‐
line, before attempting to read any input. The prompt is
displayed only if input is coming from a terminal.

使用强制伪tty分配的ssh选项-t:

ssh -t somehost ~/bashplay/f

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐