kc6ovd has asked for the wisdom of the Perl Monks concerning the following question:
The code below is from a cgi-script from a prior admin. In this sub the section for tail with grep does not display back. It seems the grep command is not working. I did remove the pipe grep from the line to make sure the if logic was working. it will display the logs, but if I try with the grep line and give it a host it will not display. I need a kick start.
##### sub tail_file { my $node = shift; my $command = (); if ($node =~ /all nodes/i) { $command = "tail -100f $logdir/syslog"; }else{ $command = "tail -100f $logdir/syslog | grep -i $node"; } my $count = 0; print "<h2>Tailing /var/log/syslog...</h2><br>\n"; open (TAIL,"$command |") or die "Can't open TAIL($command):$!\n"; while ($count <= $max) { chomp(my $line = <TAIL>); $line =~ s/\s/$space/g; print "$line<br>\n"; $count++; maxed_out() if $count >= $max } } #####
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Too many pipes?
by Eliya (Vicar) on Feb 10, 2012 at 18:32 UTC | |
by kc6ovd (Acolyte) on Feb 10, 2012 at 22:02 UTC | |
|
Re: Too many pipes?
by JavaFan (Canon) on Feb 10, 2012 at 18:25 UTC | |
by kc6ovd (Acolyte) on Feb 10, 2012 at 18:40 UTC | |
|
Re: Too many pipes?
by kc6ovd (Acolyte) on Feb 15, 2012 at 13:39 UTC |