请告诉我,我遗漏了一些非常明显的东西:
$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