通过ssh执行命令,然后运行bash

我正在尝试设置一个打开终端的脚本,对远程服务器执行ssh,并执行命令(在我的情况下是tail -F logfile)。 到目前为止我所拥有的是以下内容
gnome-terminal -e 'ssh -t server "tail -F logfile"'
这在某种程度上起作用。 -t确保通过远程运行的命令发送SIGINT之类的信号。 但是,当我按下ctrl-c尾部时,我真的想下载到远程服务器上的bash终端。现在,如果我按下ctrl-c尾部,则尾部关闭,这会导致ssh退出,这会导致整个终端关闭。 我想要的是尾部被终止并留在远程服务器上的bash shell。 我尝试过以下方法:
gnome-terminal -e 'ssh -t server "tail -F logfile; /bin/bash"'
但这似乎不起作用。也就是说,如果我在没有gnome-terminal的情况下运行它,只需要ssh -t ...,那么请看以下内容:
some lines
from the log
^CConnection to server closed.
但是,如果我这样做
gnome-terminal -e 'ssh -t server "nonexistantcommand; /bin/bash"'
然后我得到一个错误,找不到nonexistant命令,然后我下拉到远程服务器上的bash ... 有没有人对如何实现这一目标有任何建议或暗示?提前致谢。     
已邀请:
在这里,有一个讨厌的黑客:
gnome-terminal -e 'ssh -t server "echo "tail -F logfile;rm /tmp/foo" > /tmp/foo; bash --rcfile /tmp/foo"'
    
--init-file filename
--rcfile filename
  在交互式shell中执行来自filename(而不是`〜/ .bashrc')的命令。 所以用--rcfile运行bash指向运行tail -F的脚本。     
为什么不明显呢? “如果你有一个SIGINT,那就执行一个交互式shell。”
gnome-terminal -e 'ssh -t server "trap "exec sh -i" INT; tail -F logfile"'
    

要回复问题请先登录注册