vxp has asked for the wisdom of the Perl Monks concerning the following question:
I've a file to parse.
Here's a sample of its contents (this is cat -vue's output, and there are many more "sections" like the ones below in that file. about 12,000 sections like the ones below. I masked IPs, so if you see "x.x.x.x" there used to be an IP there :) ):
----- cut here ----- abc1-wl-wlc2.domain.com$ $ Successful downloads: 0$ Failed downloads: 1$ Warnings: 0$ $ Detailed Log Info$ $ General Expect Errors: 1$ Text Dump Failure: 1$ Binary Transfer Successful: 1$ Attempts to get Text Dump: 1$ Attempts to use TFTP: 1$ Attempted binary transfers: 1$ $ Textual log of the file transfer:$ Processing abc1-wl-wlc2.domain.com Performing [/usr/bin/ssh -2 -a -o " +StrictHostKeyChecking no" abc1-wl-wlc2.domain.com] Exception: 3:Child + PID 20855 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl +/ EMAN/Config/DeviceConfig/WLC.pm line 288, line 58. ExpectLog: Sorry, t +elnet is not allowed on this port!Connection to abc1-wl-wlc2.domain.c +om closed. Performing TFTP using SNMP: DestHost [x.x.x.x] Commu nity [tasMANia] agentTransferUploadServerIP [x.x.x.x] agentTransferUpl +oadFilename [x.x.x.x.UCFM.18441] Exception: 3:Child PID 20855 exited +with status 256 at /usr/SD/perl-5.6.1/lib/site_perl/EMA N/Config/DeviceConfig/WLC.pm line 288, line 58. Updating CVS$ $ apl02-wl-wlc1.domain.com$ $ Successful downloads: 0$ Failed downloads: 1$ Warnings: 0$ $ Detailed Log Info$ $ Failed Binary transfers: 1$ General Expect Errors: 1$ Text Dump Failure: 1$ TFTP failures due to SNMP set error: 1$ Attempts to get Text Dump: 1$ Attempts to use TFTP: 1$ Attempted binary transfers: 1$ $ Textual log of the file transfer:$ Processing apl02-wl-wlc1.cisco.com Performing [/usr/bin/ssh -2 -a -o " +StrictHostKeyChecking no" apl02-wl-wlc1.cisco.com] Exception: 3:Child + PID 20683 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl +/EMAN/Config/DeviceConfig/WLC.pm line 288, line 56. ExpectLog: Sorry, + telnet is not allowed on this port!Connection to apl02-wl-wlc1.cisco +.com closed. Performing TFTP using SNMP: DestHost [64.101.206.133] Co +mmunity [private] agentTransferUploadServerIP [171.70.168.173] agentT +ransferUploadFilename [64.101.206.133.UCFM.18436] Exception: Could no +t initialise SNMP [Timeout] at /usr/SD/perl-5.6.1/lib/site_perl/EMAN/ +Config/DeviceConfig/WLC.pm line 450, line 56. Exception: 3:Child PID +20683 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl/EMAN +/Config/DeviceConfig/WLC.pm line 288, line 56. Could not initialise S +NMP [Timeout] at /usr/SD/perl-5.6.1/lib/site_perl/EMAN/Config/DeviceC +onfig/WLC.pm line 450, line 56. at /usr/SD/perl/lib/site_perl/EMAN/Co +nfig/Download.pl line 888 at /usr/SD/perl/lib/site_perl/EMAN/Config/D +ownload.pl line 888$ $ ----- cut here -----
The task at hand is as follows: I need to come up with a multiline regex that matches everything between "abc1-wl-wlc2.domain.com" and "apl02-wl-wlc1.domain.com", so I can process the contents of that file, section by section. if it helps any, I'm mainly interested in getting a list of hostnames that have a "Failed Binary transfers: 1" in their section..
Any thoughts / suggestions on the multiline?
I tried doing it on my own, but unfortunatelly without much success.. I know about the "m" modifier on the end of my regex, btw. I'm not completely useless, but I can't seem to craft the necessary regex for this task :/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multi-line regex help needed
by Limbic~Region (Chancellor) on Jun 18, 2009 at 15:30 UTC | |
by vxp (Pilgrim) on Jun 18, 2009 at 15:44 UTC | |
by Limbic~Region (Chancellor) on Jun 18, 2009 at 16:15 UTC | |
by vxp (Pilgrim) on Jun 18, 2009 at 17:10 UTC | |
by Limbic~Region (Chancellor) on Jun 18, 2009 at 17:21 UTC | |
| |
by vxp (Pilgrim) on Jun 18, 2009 at 15:53 UTC | |
|
Re: Multi-line regex help needed
by BioLion (Curate) on Jun 18, 2009 at 17:12 UTC |