sqspat has asked for the wisdom of the Perl Monks concerning the following question:

Hello I am using Net::SSH::Expect to login into a device and issue commands. I also want to use the the waitfor command in the script to check for the returned result. At the moment it seems as though what is being returned is not the same as what I am telling it to expect and am not sure why??? Is there anyway of seeing what is actually returned that is then in turn being compared to what I am telling script to expect. see code and response below:
my $nav_command2 = $ssh->exec('site pat'); #insert sleep here so command can be returned. sleep(1); my $nav_command5 = $ssh->exec('no subnet 15.15.15.0/24'); $ssh->waitfor('probe161(config-site)$',1)or die "Incorrect response";
------------------ running script;
pohara@pohara-desktop:~/automation$ perl CM-CONF-001.pl Incorrect response at CM-CONF-001.pl line 58. pohara@pohara-desktop:~/automation$

Replies are listed 'Best First'.
Re: Net::ssh::Expect --Waitfor function comparison question???
by jrsimmon (Hermit) on Jul 17, 2009 at 11:23 UTC
    Methods to read from the input buffer:
    • peek() Pulls the current data from the input buffer without removing it from the buffer
    • read_line() Reads and removes the next line from the input buffer
    • read_all() Reads and removes all of the input from the buffer