Some of my peers here at Appistry have been rubbing my nose with the filtering power of grep for filtering command line utilities on 'other' operating systems for some time now. So I'm VERY excited to have figured outhow touse Microsoft's PowerShell to filter error message from our command line logging tool. - The riddle of filters.
The PowerShell syntax that really threw me involved using SQL like search syntax to build a filter. I really thought that using 'like' or 'contain' attributes on a string compare would work great, but it didn't work that way… .
The trick is to use the 'match' attribute. The real trick was not only to use match, but to make it case sensitive. AND use a not-match to get all of the log entries that are not informational (which is represented by I:0000). So NOW I have a console application that ONLY shows me warning and error message that the fabric emits.
So leveraging the ability for PowerShell to pipe data from a command into the where-object Cmdlet and using the $_ parameter to get the current-line-value the command looks like this -
PS> log_monitor 239.255.0.1:4000 | where-object {$_ -cnotmatch "I"}
I'm just scratching the surface of what I can do with Microsoft PowerShell and look forward to doing some cool things with it moving forward.
Until next time.
Mark
Technorati: Appistry Enterprise Application Fabric, Microsoft PowerShell, Monad








I agree it is just a
I agree it is just a scratch, but it is a really good example of how to do something that the UNIX world takes for granted (as they should!). It could be the beginning of a Powershell for UNIX Admins book. Now that would sell! Hmmmm? :)
L
Post new comment