http://www.perlmonks.org?node_id=994301


in reply to Re: Perl Expect is not sending multiple commands
in thread Perl Expect is not sending multiple commands

Well chalk this up to not paying attention to the output. Expect was working as expected (bad pun intended). The issue turned out to be that the 'sh ver' command contains the device name. I was looking for the device name in the expect statement. Therefore, the expect was stopping mid output. I used your example of getting the various return items to get the last character in the prompt, which I concatenated to the device name for future prompts. I had to wait until the password was successful to get that bit of information (the $after). This matters as some devices use '#' and some use '>'.

Paradise: Florida, full tank of gas, no appointments.
  • Comment on Re^2: Perl Expect is not sending multiple commands

Replies are listed 'Best First'.
Re^3: Perl Expect is not sending multiple commands
by Argel (Prior) on Sep 18, 2012 at 18:08 UTC
    Usually '#' indicates you are in enable mode and '>' indicates you are in normal mode (i.e. not all commands are available).

    I think you can do a regex like below (untested), though there is probably a cleaner/better way to do it.

    ($which,$why,$match,$before,$after) = $expect_instance->expect($Timeou +t, '-re', "(#)|(>)");

    Elda Taluta; Sarks Sark; Ark Arks
    My deviantART gallery