I have put together a script using the Perl Expect module to log into multiple hosts and execute a list of commands. I would like to be able to capture the output from each host and pattern match against it. The script (login and and issue commands) works fine, but I need some help on the capturing output piece. Is there a way to redirect from the standard out, within the script, into an array or something for parsing?
Also, if anyone knows of any good Perl Expect tutorials or demo pages, that would a big help.
What you are asking is basically the exact reason Expect was developed. You should have another look at the Expect documentation, in particular the FAQ which can be found here:
http://search.cpan.org/author/RGIERSIG/Expect-1.15/Expect.pod
You may also want to have a look through the Expect forum archives here:
http://sourceforge.net/mailarchive/forum.php?forum=expectperl-discuss
My question would be are you sure you need to be using Expect at all? how are you logging into multiple hosts, etc. Are you sure there isn't a module better suited to the task, Net::Telnet, Net::SSH::Perl, Net::FTP??
http://danconia.org
I assume it would probably happen at the point I issue my commands:
#### snippet #### open COMMAND_FILE, "<$command_file" or die "Cannot open $command_file!\n"; while (<COMMAND_FILE>) { chomp; my $command = $_; $exp->send("$command\r"); $exp->expect($timeout, "$command\r\n"); } #### snippet ####
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]