Ok thanks, for the advise, 2 questions - what did i do wrong in my
original code, cause it's based on a working example, and is IO::File
included in the default perl package ? is this script has to go on an
embedded device with as min dependencies as possible ?
Many Thanks
On 7/20/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 7/20/07, Gregory Machin <[EMAIL PROTECTED]> wrote:
> Hi
> I have a script that i'm working on, I want it to write info to a log
> file, but I can't get it to write to the file.. I run the script as
> root, and I also chmod 0777 the file but still no out put ...
> what have it missed ..
snip
Simplify, simplify, simplify.
#!/usr/bin/perl
use strict;
use warnings;
use IO::File;
my $wait = 10;
my $logfile = "/var/log/ifwatch";
my $continue = 1;
open my $log, ">>", $logfile
or die "could not open $logfile:$!";
$log->autoflush(1);
#### process handeling kill and restart call
$SIG{INT} = $SIG{TERM} = sub {
print $log localtime() . " Exiting...\n";
$continue = 0;
};
$SIG{HUP} = sub {
print $log localtime() . " Restarting...\n";
exec ($0, @ARGV) or die "Could not restart: $!\n";
};
open STDIN, "<", "/dev/null"
or die "could not redirect stdin: $!";
print $log localtime() . " ifwatch starting\n";
while ($continue) {
#do stuff
print $log localtime() . " sleeping\n";
sleep $wait;
}
print $log localtime() . " ifwatch exiting\n";
--
Gregory Machin
[EMAIL PROTECTED]
www.linuxpro.co.za
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/