good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Screen Scraping from Juniper Switch using Expect.pm - Multiple Commandsby julio-johnson (Initiate) |
on May 05, 2015 at 02:10 UTC ( [id://1125652]=perlquestion: print w/replies, xml ) | Need Help?? |
julio-johnson has asked for the wisdom of the Perl Monks concerning the following question: Hello, I'm trying to do some telnet/ssh (start with telnet for simplicity) screen scraping from a Juniper switch (netconf/snmp aren't available) using the Expect.pm perl module. My goal is to be able to shove the output of a few commands into an array for each command. For example: "show version" goes to @show_version and "show interfaces" goes to @show_interfaces I've consulted http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod#NAME I am failing utterly at this. I can login to the switch and do a basic command and then wait for the session to timeout. I've tried various combinations but I've so far failed at: 1. Understanding the flow control logic of the Expect module. So to figure out I'm logged in, I need to look for a CLI prompt. But how do I tell the difference between the initial login vs. subsequent prompts (after the successful completion of a CLI command)? 2. How do I piggy back several show commands together without logging out each time? I see that as part of the module's FAQ (How to expect on multiple spawned commands) where it mentions the -i parameter but I just don't get it.
Back to
Seekers of Perl Wisdom
|
|