diligent has asked for the wisdom of the Perl Monks concerning the following question:
From a shell, I can easily execute the 2nd command (PL) and it will return the percentage of packet loss in the new log file ($TARGET_HOST.PL.log). However, when I run the script, the new log file is created, however there is nothing in it. Any help is appreciated!my @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday +); my @shortdays = qw( Sun Mon Tue Wed Thu Fri Sat ); my @months = qw(January February March April May June July August Sept +ember October November December); my @shortmonths = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) +; my ( $sec, $min, $hr, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); my $longyr = $year + 1900; my $fixmo = $mon + 1; $LOGFILE = ">/home/***/public_html/packet/logs/$TARGET_HOST.$mday-$ +shortmonths[$mon]-$longyr.log"; open(LOGFILE) || die "Log file will not open.\n"; print LOGFILE "--------- $mday $shortmonths[$mon], $longyr, $hr:$mi +n:$sec ---------\n\n"; print "Content-type: text/html\n\n"; print "<HTML><PRE>\n"; print "<B>Please wait for script to run, or time out</B>\n"; open (IX,"$commands{$PROGRAM} $TARGET_HOST |"); while (<IX>) { chop $_; print "$_\n"; print LOGFILE "$_\n"; } print <<__END_OF_FOOTER__; </PRE> </HTML> __END_OF_FOOTER__ close (IX); $PACKET = ">/home/***/public_html/packet/logs/$TARGET_HOST.PL.$mday +-$shortmonths[$mon]-$longyr.log"; open(PACKET) || die "Packet loss file will not open.\n"; open (PL,"grep 'packet loss' /home/***/public_html/packet/logs/$TAR +GET_HOST.$mday-$shortmonths[$mon]-$longyr.log | cut -d ' ' -f 6 | cut + -d '%' -f1 > /home/***/public_html/packet/logs/$TARGET_HOST.PL.log") +; close (PL);
Node content restored by GrandFather
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File created but blank
by GrandFather (Saint) on Jul 24, 2008 at 04:24 UTC | |
|
Re: File created but blank
by pc88mxer (Vicar) on Jul 24, 2008 at 03:23 UTC | |
|
Re: File created but blank
by jethro (Monsignor) on Jul 24, 2008 at 03:21 UTC | |
by Fletch (Bishop) on Jul 24, 2008 at 12:57 UTC | |
|
Re: File created but blank
by Lawliet (Curate) on Jul 24, 2008 at 03:22 UTC | |
|
Re: File created but blank
by kabeldag (Hermit) on Jul 24, 2008 at 03:21 UTC | |
|
Re: File created but blank
by cdarke (Prior) on Jul 24, 2008 at 07:54 UTC |