From: Ken I. <fn...@ua...> - 2007-11-14 21:57:28
|
On Wed, Nov 14, 2007 at 03:39:45PM -0600, Noah wrote: > > Bradford Ritchie wrote: >> On Nov 14, 2007 3:46 PM, Noah <ad...@en... >> <mailto:ad...@en...>> wrote: >> > >> > I'm assuming the output is coming from a remote connection to something, >> > not a command run at the shell... I'm pretty sure expect can do that, >> > but I would need more details. Can you give some sample output and an >> > example of what you consider a "match" that you want to save? You'll >> > probably end up calling expect over and over again to get each match, so >> > that means you may also need to look for something that tells you when >> > to stop looking. >> > >> Hi, >> okay I am attempting to grab the interface and Unit number like >> t1-1/1/0.0 for each logical interface to t1-1/1/0.9, the Input rate, >> Output rate, and the remote IP address out of the following output: >> sample output - yup the results from a JUNOS CLI command. >> *Sounds like you really only need expect to do the remote connection/login >> part. If it were me, I would do the minimum with expect to just send the >> command and capture all of the output to an array (ie. one call to expect, >> using the prompt as the "match" string), and then parse the output the way >> you would normally parse an input stream, like with a foreach loop or >> something. > > is there a way to capture the output with perl-expect into an array? One way would be to receive a string and split it aftwards, e.g., $foo->expect($timeout, 'regex', $some_terminating_pattern); my @results = split /\n/, $foo->match(); ... Ken -- Ken Irving, fn...@ua... |