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 ..

___script___


#!/usr/bin/perl
print "hello";

#### use
use strict;
#package ifwatch;

### global vars
my $primaryif = "/dev/ttyACM0";
my $secondaryif = "/dev/ttyACM1";
my $primaryconfig = "/etc/ifwatch/ACM0";
my $secondayconfig = "/etc/ifwatch/ACM1";
my $currentif;
my $mainloopsleep = 10;
my $LOG_DIR = "/var/log";

&daemonize();
&main();

#### process handeling kill and restart call
$SIG{INT} = sub
{
  print STATUS_LOG localtime() . " Exiting...\n";
  close (DEBUG_LOG);
  close (ERROR_LOG);
  exit;
};

$SIG{HUP} = sub
{
  print STATUS_LOG localtime() . " Restarting...\n";
  exec ($0, @ARGV) or die "Could not restart: $!\n";
  close (STATUS_LOG);
  close (STATUS_LOG);
  exit;
};




sub ifcheck{
#my $files = "/dev/xtty0";
#Bunless (open(TESTFILE, $files)){
#die ("File  does not exist");
#}
}


##### daemonize
sub daemonize {

#  use POSIX qw(setsid);
 open (STDIN, "/dev/null");
 open (STATUS_LOG, ">> /var/log/ifwatch");
#  defined(my $pid = fork) or die "Can't fork: $!";
#  exit if $pid;

             }

#### main loop
sub main {

print STATUS_LOG localtime() . " hello ";

  my $loop = 1;
  while ($loop >= -1)
    {
      print STATUS_LOG localtime() . " sleeping\n";
      sleep $mainloopsleep;
    }

print STATUS_LOG localtime() . " ifwatch exiting";
close (STATUS_LOG);
}


1
;





--
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/


Reply via email to