Subject: help needed to read /var/run/log with Perl
To: None <netbsd-help@netbsd.org>
From: Joel CARNAT <joel@carnat.net>
List: netbsd-help
Date: 03/11/2005 19:57:50
Hi,
Not 100% NetBSD, but my problem is on a NetBSD machine ;)
I want to write a small script that reads /var/run/log (ala tail -f)
and print things according to parsing rules. Thanks to google,
I wrote this :
####################################
#!/usr/pkg/bin/perl -w
#
# Bind to /var/run/log and parse lines
#
use strict;
use Socket;
my ($rendezvous, $line);
$rendezvous = shift || '/var/run/log';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
connect(SOCK, sockaddr_un($rendezvous)) || die "connect: $!";
while (defined($line = <SOCK>)) {
print $line;
}
exit;
####################################
# file /var/run/log
/var/run/log: socket
# ./parselogd.pl
connect: Protocol wrong type for socket at ./parselogd.pl line 12.
I just don't get why '/var/run/log' is not SOCK_STREAM.
Anyone can help ?
PS: syslog-ng is running and readin /var/run/log too (if it helps :)
TIA,
Jo
--
,- This mail runs ------.
`--------- NetBSD/i386 -'