Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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(); }

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 avoiding work at the Monastery: (9)
As of 2021-03-05 14:23 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (112 votes). Check out past polls.