vmp*_*str 5 ssh bash gnome-terminal
我正在尝试设置一个打开终端的脚本,对远程服务器执行ssh,并执行命令(在我的情况下是tail -F logfile).
到目前为止我所拥有的是以下内容
gnome-terminal -e 'ssh -t server "tail -F logfile"'
Run Code Online (Sandbox Code Playgroud)
这在某种程度上起作用.-t确保通过远程运行的命令发送SIGINT之类的信号.
但是,当我按下ctrl-c尾部时,我真的想下载到远程服务器上的 bash终端.现在,如果我按下ctrl-c尾部,则尾部关闭,这会导致ssh退出,这会导致整个终端关闭.
我想要的是尾部被终止并留在远程服务器上的bash shell.
我尝试过以下方法:
gnome-terminal -e 'ssh -t server "tail -F logfile; /bin/bash"'
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.也就是说,如果我在没有gnome-terminal的情况下运行它,只需要ssh -t ...,那么请看以下内容:
some lines
from the log
^CConnection to server closed.
Run Code Online (Sandbox Code Playgroud)
但是,如果我这样做
gnome-terminal -e 'ssh -t server "nonexistantcommand; /bin/bash"'
Run Code Online (Sandbox Code Playgroud)
然后我得到nonexistantcommand没有发现错误,然后我就下降到一个bash在远程服务器上...
有没有人对如何实现这一目标有任何建议或暗示?提前致谢.
在这里,有一个令人讨厌的黑客:
gnome-terminal -e 'ssh -t server "echo \"tail -F logfile;rm /tmp/foo\" > /tmp/foo; bash --rcfile /tmp/foo"'
Run Code Online (Sandbox Code Playgroud)