develooper Front page | perl.beginners | Postings from October 2009

Something silly I'm not seeing.. flt script is written to.

Thread Next
From:
Harry Putnam
Date:
October 17, 2009 00:02
Subject:
Something silly I'm not seeing.. flt script is written to.
Message ID:
87eip2ec5l.fsf@newsguy.com
I wrote a quick filter for system-log output but must have done
something really dumb because syslog is writing to the script (through
a named-pipe).

This is on opensolaris... The system logger syslog.conf file doesn't
allow the use of a pipe symbol like can be done on linux OS's, for
sending syslog output to a named pipe.

The script opens the named-pipe for reading

But the data is actually being written into the script.  Egad... that
seems pretty crazy.  When I start the script with `./flt' it does not
write to any files... or to stdout, instead the data is coming through
the named-pipe and being written into the script file.  The data is
being appended to the script instead of the expected files.

I think I must have gotten a variable confused in there but I'll be
damned if I can see it.

Also wondered if there might be something peculiar about the
named-pipe so running `file slpipe'... it shows:

   # file slpipe
  slpipe:         fifo

As expected.

Here is the script... I've looked hard at it but not seeing why this
is happening (The extra prints were there just to see if any data was
coming through):

#!/usr/local/bin/perl

use strict;
use warnings;

my $idmap_rgx = qr/ idmap\[\d+\]:/;
my $sshd_rgx = qr/ sshd*\[\d+\]:/;

my $sshd_log  = '/var/adm/sshd.log';
my $idmap_log = '/var/adm/idmap.log';
my $pipe = '/var/adm/slpipe';

open(SSHD_LOG,">> $sshd_log")or die "Can't open $sshd_log: $!";
open(IDMAP_LOG,">> $idmap_log")or die "Can't open $idmap_log: $!";

if (open(PIPE, "<$pipe")) {
   while (<PIPE>) {
      if(/$idmap_rgx/){
         print IDMAP_LOG $_;
         print;
      }elsif(/$sshd_rgx/){
         print SSHD_LOG $_;
         print;
      }
   }
}


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About