9

我确保在 .bashrc 中定义了 TERM。

但是,在批处理模式下运行 ssh 时,我得到:

 $ ssh pc-lab7 "echo $TERM; echo $0"
    TERM environment variable not set.
    linux
    -bash

如果我在交互模式下运行 ssh,我看不到这个错误。

如何消除此错误消息?

4

2 回答 2

13

使用-tssh 选项分配 tty

 -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.
于 2014-07-26T13:33:03.600 回答
7

我终于找到了这个烦人的“未设置TERM环境变量”警告的原因。

事实证明,当 ssh 在没有交互式用户的情况下以批处理模式执行时,在启动脚本中调用“清除”命令将产生此错误。

注释掉脚本中的“清除”行为我解决了这个问题。

于 2012-04-18T14:37:17.943 回答