码迷,mamicode.com
首页 > 其他好文 > 详细

ssh自动化出现的莫名报错

时间:2014-09-25 22:10:27      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   使用   ar   for   

代码如:

ssh -q user@host <<EOF
  ping -c 3 localhost
EOF

会出现提示如:

Pseudo-terminal will not be allocated because stdin is not a terminal.

google了下,有人提出加上-T(ssh -T -q user@host)参数可避免此情况。如这篇文章介绍的:

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禁用该行为即可。

ssh自动化出现的莫名报错

标签:style   blog   http   color   io   os   使用   ar   for   

原文地址:http://www.cnblogs.com/lichmama/p/3993683.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!