Pergunta

I'm trying to set up a script that opens a terminal, does an ssh to a remote server, and executes a command (tail -F logfile in my case).

What I have so far is the following

gnome-terminal -e 'ssh -t server "tail -F logfile"'

This works to some extent. -t ensures that signals like SIGINT are sent through the commands running remotely.

However, when I ctrl-c the tail, I would really like to drop down to a bash terminal on the remote server. Right now, if I ctrl-c the tail, then the tail is closed, which causes ssh to exit, which causes the whole terminal to be closed.

What I would like is for the tail to be terminated and be left with a bash shell on the remote server.

I have tried the following:

gnome-terminal -e 'ssh -t server "tail -F logfile; /bin/bash"'

but that doesn't seem to work. That is, if I run this without gnome-terminal, just ssh -t ..., then see the following:

some lines
from the log
^CConnection to server closed.

But, If I do

gnome-terminal -e 'ssh -t server "nonexistantcommand; /bin/bash"'

Then I get an error that nonexistantcommand is not found, and then I do drop down to a bash on a remote server...

Does anyone have any suggestions or hints on how to get this going? Thanks in advance.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top