Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Sys::Syslog no output

by sunadmn (Curate)
on Jan 23, 2006 at 17:03 UTC ( #524971=perlquestion: print w/ replies, xml ) Need Help??
sunadmn has asked for the wisdom of the Perl Monks concerning the following question:

For some reason I am not getting anything to syslog and I am lost to where I went wrong. Anyone have any ideas on this one??
#!/usr/bin/perl use strict; use Sys::Syslog; my $dir = "/usr/local/chaser/"; my $file = "load_data_file.*"; my $ls = '/bin/ls'; my $wc = "/bin/wc -l"; my $cmd = "$ls $dir" . "$file \|" . "$wc"; open(RET, "$cmd |"); chomp(my @return = <RET>); close(RET); if(@return >1) { openlog("files", "user", "system"); syslog('alert', '%s', 'this is a test'); closelog(); }

Comment on Sys::Syslog no output
Download Code
Replies are listed 'Best First'.
Re: Sys::Syslog no output
by McDarren (Abbot) on Jan 23, 2006 at 17:55 UTC
    The line:
    if (@return > 1)
    is evaluating @return in scalar context. And because your $cmd returns just a single line, you are effectively saying:
    if (1 >1)
    of course, 1 will never be greater than 1, so you get no output :p
    Change it to:
    if (@return) {

    Darren :)

      Ahhh thank you a million times over that did the trick.
      USE PERL
Re: Sys::Syslog no output
by ides (Deacon) on Jan 23, 2006 at 17:27 UTC

    I believe your openlog() is wrong. It should be:

    openlog('files', 'pid', 'user');

    I think that's what you're looking for.

    Frank Wiles <>

      Hmm I did try that and still for some reason nothing.
      USE PERL
Re: Sys::Syslog no output
by radiantmatrix (Parson) on Jan 23, 2006 at 17:55 UTC
Re: Sys::Syslog no output
by idsfa (Vicar) on Jan 23, 2006 at 17:54 UTC

    Does your OS support a logging facility called system (not to be confused with syslog)? If so, is it being logged where you think it is being logged (check /etc/syslog.conf)?

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://524971]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2015-11-27 01:54 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (712 votes), past polls