11

Is there any way to disable or set the page-length of a ruby Net-SSH connection so we don't have to change the settings on the remote device?

In Cisco routers we would use the parameters "terminal length 0" to accomplish this but on other servers we can't use any simular commands. Can this be set via the Net-SSH lib?

Bulki
  • 734
  • 1
  • 10
  • 30
  • A possible workaround would be `export PAGER=cat`. – Jordan Running Apr 26 '16 at 15:09
  • @Jordan I tried this but it didn't work. I've added the line in my .bashrc – Bulki Apr 29 '16 at 11:14
  • 1
    can you paste how you are using net-ssh? – Anko May 02 '16 at 05:50
  • 2
    I personally don't believe you will be able to do this, as paging usually occurs on the server side. Another option would be to use something like [PTY](http://ruby-doc.org/stdlib-1.9.3/libdoc/pty/rdoc/PTY.html) and [expect](http://ruby-doc.org/stdlib-2.1.0/libdoc/pty/rdoc/IO.html) to handle the pager. – Cory Shay May 04 '16 at 21:35

1 Answers1

1

Assuming the remote end has a shell then the terminal height is set in the LINES environment variable. You can try setting it like this:

Net::SSH.start('hostname', 'user') do |ssh|
  ssh.exec!('LINES=50 your-command-here')
end

If you don't have a shell you can try having net-ssh push it:

ENV['LINES'] = '50'
Net::SSH.start('hostname', 'user', send_env: ['LINES']) do |ssh|
  ssh.exec!('your-command-here')
end

However, this requires the cooperation of sshd. If it's OpenSSH, edit /etc/ssh/sshd_config and make sure AcceptEnv includes LINES.

Loops
  • 101
  • 2