[syslog-ng]how to pass a value from an expanded macro to an external program?

UNIX Admin syslog-ng@lists.balabit.hu
Thu, 7 Apr 2005 15:50:20 -0700


D'oh! I left off the -n on the she-bang line:

#!/usr/bin/perl -n

...to make it behave correctly, but I'm sure you would have figured that out.

On Apr 7, 2005 3:48 PM, UNIX Admin <infosec@gmail.com> wrote:

> You could modify the example at http://www.campin.net/perl-mail.txt to
> do it for you, something like:
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> # strip the priority
> s/^<[\d]{1,2}>//;
> 
> if ( /[A-Z][a-z]{2}\s{1,2}\d{1,2}\s\d{2}:\d{2}:\d{2}\s(\w+)\s/ ) {
>         system("echo \"$_\" | /usr/bin/mailx -s \"log alert on host:
> $1\" user\@domain");
> } else {
>         system("echo \"$_\" | /usr/bin/mailx -s \"log alert on unknown
> host\" user\@domain");
> }
> 
> __END__
> 
> The information is there, you just have to get it yourself.
>