Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Perl Expect is not sending multiple commands

by essej1 (Novice)
on Sep 18, 2012 at 15:33 UTC ( #994301=note: print w/ replies, xml ) Need Help??


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
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994301]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-12-26 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls