mrbullman has asked for the wisdom of the Perl Monks concerning the following question:
Wondering if there is a simple solution to the coding problem I have encountered. I ssh into a box and run a command to show some settings how ever if the amount of data returned is larger than the screen window you have to hit a key to continue. Is there a way to simulate hitting a key to continue printing the output to a file? ssh -l admin xxx.xxx.xxx.xxx admin's password: xxxxx
#!/bin/perl use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => $host, password=> $pass, user => $user, raw_pty => 1, timeout => 3 ); my $login_output = $ssh->login(); if ($login_output !~ />/) { die "Login has failed. Login output was $login_output"; } my $who = $ssh->send("show config\n"); while ( defined ($line = $ssh->read_line()) ) { print $line . "\n"; } close $line; $ssh->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wait for string
by atcroft (Abbot) on Apr 28, 2015 at 01:00 UTC | |
|
Re: Wait for string
by Happy-the-monk (Canon) on Apr 28, 2015 at 05:18 UTC | |
|
Re: Wait for string
by Marshall (Canon) on Apr 28, 2015 at 00:52 UTC | |
|
Re: Wait for string
by flexvault (Monsignor) on Apr 27, 2015 at 23:20 UTC | |
|
Re: Wait for string
by mrbullman (Initiate) on Apr 28, 2015 at 14:38 UTC |