批处理模式SSH提供错误"未设置TERM环境变量"

Yor*_*amW 8 linux ssh

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

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

 $ ssh pc-lab7 "echo $TERM; echo $0"
    TERM environment variable not set.
    linux
    -bash
Run Code Online (Sandbox Code Playgroud)

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

如何消除此错误消息?

Tha*_*wda 8

使用-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.
Run Code Online (Sandbox Code Playgroud)


Yor*_*amW 6

我终于找到了这个恼人的"TERM环境变量未设置"警告的原因.

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

在脚本中注释掉"清晰"一行可以解决我的问题.