On Fri, 14 Sep 2001, Jorge Goncalvez wrote:
> Thanks for your tips Todd but My if is never verified in:
>
> if ($_==~ /DHCPDISCOVER/ && <whatever>)
> {......
> }
>
> althought $_=' dhcpd : LOG_INFO : DHCPDISCOVER from
> 02:41:53:20:d0:34:5b:a6:ef:3c:c1:01:01:00:00:00 via eth0.
>
> Why?
Well, my suggestion wasn't an if construct, that's why. :) If you want to
match an entire string as an exact match (i.e. same interface, same MAC
address, etc.), then your approach works fine. But if you just want to
match any line containing DHCPDISCOVER, you need to construct a regex.
That said, TMTOWTDI. My original suggestion was to use the high-priority
AND operator ("&&") to take an action if a match was found. You can also
use something like this, which will act more or less like grep:
perl -ne 'print if /DHCPDISCOVER/' /var/log/messages
Come to that, you can always use grep directly. Mostly, it comes down to
what you want to *do* with the information once you've matched it.
--
Work: It's not just a job, it's an indenture.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]