使用ssh时bash中缺少“read”提示?

2024-09-30 18:21:06 发布

您现在位置:Python中文网/ 问答频道 /正文

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

$ 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

使用ssh时,请注意缺少的“RDY>;”提示。在使用“readline”包时,我在python中看到了同样的情况。有人知道为什么吗?在


Tags: echogtbashreadbinsshviacat
1条回答
网友
1楼 · 发布于 2024-09-30 18:21:06

{From>

-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.

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

ssh -t somehost ~/bashplay/f

相关问题 更多 >