Hey All, I have a perl script here (below) that becomes a daemon when ever I run it. But when ever it goes to read the script it it dies on me?
Can any one tell me what is going on here? If I remark (#) the read_config(); in the while loop the daemon doesn't break. Does any one here have any suggestions? Regards, Dan #!/usr/bin/perl -w use POSIX qw(setsid); use Data::Dumper; use Net::SSH::Perl; chdir '/' or die "Can't chdir to /: $!"; umask 0; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; #open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!"; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; my $tunnelfile = 'config'; #Sets the config file as $tunnelfile. my $sleep = 2; #How long do you want the script to check for IP change? my $srt = 0; my %tunnels; while(1) { sleep(1); print "Hello...\n"; system ("ifconfig ppp0 > /etc/ppp/ppp.txt"); open (FH, "</etc/ppp/ppp.txt"); #...and open the textfile for reading @test=<FH>; #Store ppp0 as an array $test[1] =~ /addr:(\d+\.\d+.\d+\.\d+)/; #Extact the IP address here and stote as $1 close(FH); read_config(); } sub read_config { open (FILE, "<$tunnelfile") or die "cannot open '$tunnelfile': $!\n"; while( <FILE> ) { my $tunnelname = $1 and next if /^\s*\[\s*(.*?)\s*\]\s*$/; next unless defined $tunnelname && /^\s*(.*?)\s*=\s*(.*?)\s*$/; $tunnels{$tunnelname}{$1} = $2; } close(FILE); return %tunnels; } ============================== VINTEK CONSULTING PTY LTD (ACN 088 825 209) Email: [EMAIL PROTECTED] WWW: http://www.vintek.net Tel: (08) 8523 5035 Fax: (08) 8523 2104 Snail: P.O. Box 312 Gawler SA 5118 ============================== -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]