0
ssh remotehost "remote_command" | more

This executes remote_command on remotehost, and paginates the output of remote_command. If the user is unwilling to scroll through all the pages, he might press q at the --MORE-- prompt. Unfortunately this doesn't stop the ssh process (and the remote command). The user have to press ^C to actually terminate the processes. When user presses q more terminates and ssh gets SIGPIPE but continues as remote_command didn't finish executing. Is there any way I can terminate ssh and remote execution when the user quits the pager? I don't want the user to press ^C as he wouldn't be required to do so if a local file was being catted (in fact he wouldn't know this command is being executed over a ssh tunnel remotely).

2 Answers 2

1

Why not just change the command to call more on the remote server? Also you will have to force a pty as wfaulk mentioned. Assuming it is another unix system this should be fine. i.e.

ssh -t name@system "command | more"

Fyi. less is more :)

1
  • Forcing a terminal is messing up with newlines etc. And again, pagination on remote side is not good as I am on a terminal (router CLI shell) which has configurable number of lines per page - and that can't be communicated to pager on remote side.
    – Anonymous
    Oct 17, 2009 at 13:32
0

I haven't tested this, but try getting a pty from the remote machine by passing the '-t' flag to ssh.

You must log in to answer this question.