Running a command on ssh and then running bash

I am trying to configure a script that opens a terminal, does ssh on a remote server and executes a command (tail -F logfile in my case).

So far, I have been next

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

It works to some extent. -t ensures that signals such as SIGINT are sent through remotely executed commands.

However, when I ctrl-c tail, I would really like to go down to the bash terminal on the remote server. Right now, if I have ctrl-c tail, then the tail is closed, which causes ssh to exit, which causes the entire terminal to close.

I want the tail to be completed and stay with the bash shell on the remote server.

I tried the following:

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

but this does not seem to work. That is, if I ran this without gnome-terminal, just ssh -t ..., you will 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"'

, nonexistantcommand , bash ...

- , ? .

+5
3

:

gnome-terminal -e 'ssh -t server "echo \"tail -F logfile;rm /tmp/foo\" > /tmp/foo; bash --rcfile /tmp/foo"'
+2
--init-file filename
--rcfile filename

( `~/.bashrc ') .

bash --rcfile, script -F.

+1

Why not make the obvious? "If you have SIGINT, run the interactive shell."

gnome-terminal -e 'ssh -t server "trap \"exec sh -i\" INT; tail -F logfile"'
+1
source

All Articles