Home > Archive > PERL CGI Beginners > February 2005 > tail -f in cgi
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| sc0ri0n 2005-02-18, 3:55 am |
| Hi,
I want to be able to tail -f log files on a different machine and display
the results in a web page. Below code from the cgi works:
$cmd = "rsh -l $acc $Host tail -f $LogFileName |";
$count=0;
open LOG, $cmd or die "Could not open file: $!";
while (<LOG> ){
$_ =~ s/\&/&/g;
$_ =~ s/\</</g;
$_ =~ s/\>/>/g;
print "$_";
last if (count++ >100);
}
exit;
However; problem is that I can not end the session! If for example a user
clicks stop; or closes the window, on the target machine, I still see
'tail -f $LogFileName' under $acc user...
It looks like the above cgi does not stop neither the rsh connection.
Did anyone do something like this? How is it possible to close the
connection?
Thanks,
Adil
| |
| kevindotcar 2005-02-28, 3:55 am |
|
sc0ri0n wrote:
> Hi,
>
> I want to be able to tail -f log files on a different machine and
display
> the results in a web page. Below code from the cgi works:
>
> $cmd = "rsh -l $acc $Host tail -f $LogFileName |";
> $count=0;
> open LOG, $cmd or die "Could not open file: $!";
> while (<LOG> ){
> $_ =~ s/\&/&/g;
> $_ =~ s/\</</g;
> $_ =~ s/\>/>/g;
>
> print "$_";
> last if (count++ >100);
> }
> exit;
>
>
> However; problem is that I can not end the session! If for example a
user
> clicks stop; or closes the window, on the target machine, I still see
> 'tail -f $LogFileName' under $acc user...
>
> It looks like the above cgi does not stop neither the rsh connection.
>
> Did anyone do something like this? How is it possible to close the
> connection?
>
> Thanks,
> Adil
Hi-
I'd just write a tag like
<meta http-equiv="refresh" content="10">
to the browser, and change your $cmd line to something like
> $cmd = "rsh -l $acc $Host tail -100 $LogFileName |";
This will dump the last 100 lines to your user's browser
every ten seconds- Tune to your taste; No worries, mon.
K.C
|
|
|
|
|