redirect to syslog

S

sbk

hi,

i have an application which insists on writing to its own log file,
rather than to syslog. rather than modifying the application, i would
like to intercept what it sends to this file and redirect it to syslog

i'm imagining that i can write a program to do this ... but i'm having
trouble getting started. would someone familiar with this process
offer me key words?

[is this a 'named pipe' that i want to create? i'm imagining that i
would replace the application's logfile with a 'named pipe' and then
write a perl program to read from that named pipe ... that program
would write whatever it received from the named pipe to syslog. as
long as my program continues to function ... the application outta be
just fine ... ;) ]

--sk

stuart kendrick
fhcrc
 
M

Mark Bole

sbk said:
hi,

i have an application which insists on writing to its own log file,
rather than to syslog. rather than modifying the application, i would
like to intercept what it sends to this file and redirect it to syslog

i'm imagining that i can write a program to do this ... but i'm having
trouble getting started. would someone familiar with this process
offer me key words?

[is this a 'named pipe' that i want to create? i'm imagining that i
would replace the application's logfile with a 'named pipe' and then
write a perl program to read from that named pipe ... that program
would write whatever it received from the named pipe to syslog. as
long as my program continues to function ... the application outta be
just fine ... ;) ]

This isn't directly a Perl-related question, it's a Unix question.

For a Unix system, read the man page for "mknod", with the "p" (for
"pipe") option.

Here is a partial extract of Perl code dealing with Unix pipe files:

unless (-p $pipe_file) {
unlink $pipe_file;
system('mknod', $pipe_file, 'p')
&& warn "can't mknod $pipe_file: $!";
}

-Mark Bole
 
J

John W. Krahn

Mark said:
sbk said:
i have an application which insists on writing to its own log file,
rather than to syslog. rather than modifying the application, i would
like to intercept what it sends to this file and redirect it to syslog

i'm imagining that i can write a program to do this ... but i'm having
trouble getting started. would someone familiar with this process
offer me key words?

[is this a 'named pipe' that i want to create? i'm imagining that i
would replace the application's logfile with a 'named pipe' and then
write a perl program to read from that named pipe ... that program
would write whatever it received from the named pipe to syslog. as
long as my program continues to function ... the application outta be
just fine ... ;) ]

This isn't directly a Perl-related question, it's a Unix question.

For a Unix system, read the man page for "mknod", with the "p" (for
"pipe") option.

Here is a partial extract of Perl code dealing with Unix pipe files:

unless (-p $pipe_file) {
unlink $pipe_file;
system('mknod', $pipe_file, 'p')
&& warn "can't mknod $pipe_file: $!";
}

No need to run an external program to create a FIFO:

use POSIX 'mkfifo';

unless ( -p $pipe_file ) {
unlink $pipe_file or die "Can't unlink $pipe_file: $!";
mkfifo $pipe_file or die "Can't mkfifo $pipe_file: $!";
}



John
 
A

Anno Siegel

Jim Gibson said:
Then it will be necessary to modify that program. It is not possible,
as far as I know, to externally change output to a regular file into
output to a named pipe, unless there are some redirection tricks I
don't know about.

Why on earth not? Instead of letting the program create its log file,
pre-create it as a named pipe and let the program pick it up. A demon
can listen on the read end and forward the info to syslog. No tricks
involved. I'm not saying it's the best solution, but it's certainly
possible.

[sensible alternatives snipped]

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top