Ok so I rewrote the sub letting perl handle the work rather than system calls.

This is a bit sloppy I admit. But it is a working solution to the issues. Keep in mind this is feeding a CGI script on a system I do not have access to. All the output is displayed to the user via a web browser. Please comment on any clean up.

##### sub tail_file { my $node = shift; my $name="/var/log/syslog"; my $x = -1; if ($node =~ /all nodes/i){ $x = 15; } print "<h2>Tailing /var/log/syslog...</h2><br>\n"; use File::Tail; my $file=File::Tail->new(name=>$name, tail=>$x); while (defined(my $line=$file->read)) { if ($node =~ /all nodes/i) { print "$line<br>\n"; }else{ my @line2 = grep {/$node/i} $line; foreach my $line3 (@line2) { chomp $line3; $line3 =~ s/\s/$space/g; print "$line3<br>\n"; } } } } #####

In reply to Re: Too many pipes? by kc6ovd
in thread Too many pipes? by kc6ovd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.