我正在尝试通过ssh连接到服务器。一旦连接成功,终端应该被清除。
由于生成了密钥,我可以通过ssh usr@svr
连接到服务器,而不需要输入密码。这个方法是可行的。
为了摆脱
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
我通常只需键入clear
即可。但是,我希望能够自动化这个过程,而不必每次都键入此命令。
ssh usr@svr "clear"
--> "TERM环境变量未设置。"。我在谷歌上搜索了几种有关未设置环境变量的解决方案,但没有成功。
因此,我尝试了ssh -t usr@vr "clear"
;这成功地清除了终端,但也立即关闭了连接("Connection to IP closed.")。计算机连接到服务器,清除屏幕,然后关闭连接。
下一个尝试是在连接到服务器后创建一个bash脚本来运行。
#/bin/bash
clear
## cl.sh, chmod +x
ssh usr@svr ./cl.sh
--> "TERM环境变量未设置。"
另一种尝试是创建一个bash脚本通过ENDSSH
连接到服务器并清除终端。
#/bin/bash
ssh usr@svr <<'ENDSSH'
clear
ENDSSH
## sc.sh, chmod +x
运行这个操作的结果是:
> ./sc.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
Linux raspberrypi 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
TERM environment variable not set.
我是一个初学者,如果我犯了一个非常明显的错误,请耐心等待。在发布前,我尽可能详尽地研究了这个问题,但找不到答案。例如,除了 "clear" 命令以外的命令工作正常(ssh usr@svr ls
),但这对我没有帮助。