代码如:
ssh -q [email protected] <<EOF ping -c 3 localhost EOF
会出现提示如:
Pseudo-terminal will not be allocated because stdin is not a terminal.
google了下,有人提出加上-T(ssh -T -q [email protected])参数可避免此情况。如这篇文章介绍的:
http://buralin.iteye.com/blog/2035691
参数解释:
-T Disable pseudo-tty allocation. -t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
基于上述可以看出,当调用一个使用ssh自动化的脚本时,ssh登录到远程后会当前角色分配一个tty,但由于当前登录模式并非本地模式所以就会报错。
所以使用-T禁用该行为即可。
时间: 2024-11-15 23:20:10