Re: Close a Running Sub-Process



mumebuhi <mumebuhi@xxxxxxxxx> wrote:
I have a problem closing a filehandle, which is a pipe to a forked
process. The forked process basically tails a log file in another
server. I need to stop the child process once a particular line is
found.

The code is as the following:

It is not valid Perl code for a start.

use warnings;
use strict;

Would have should you that. Actually it will not compile anyway.

# start code
my $fh = undef;
my $child_process = "ssh username@host tail --follow=name
file_to_be_tailed"

No ; at end of statement.

open $fh, $child_process || Carp::confess("can't open $child_process:
$!");

The format of $child_process shows that you are trying to open a file
for reading, nothing more... and the || has a high prority so as long as
$child_process is true then the right-hand side will be ignored.

while (<$fh>) {
chomp;
if (/successful/) {
last;
}
}
close $fh;
# end code

The script will block when it tries to close the filehandle. How do I
force it to close while tail is still running?

Not sure what is going on... but I suggest you clean up your code
properly first.

Axel


.



Relevant Pages

  • Close a Running Sub-Process
    ... The forked process basically tails a log file in another ... server. ... The script will block when it tries to close the filehandle. ...
    (comp.lang.perl.misc)
  • Re: Reinstalling Exchange to a new 2000 installation
    ... CLEAR OUT the database and log file directories. ... file in the directory it did not come along with the restore. ... >restore the databases and start them up on this server. ...
    (microsoft.public.exchange2000.win2000)
  • Re: Excessive amount of log files
    ... Based on that information I would say that your server is doing fine. ... 5mb attachment that will be 40Mb of transaction logs right there. ... an Exchange server will also cause transactions to be recorded. ... What we look for in high log file growth situation is large numbers of log ...
    (microsoft.public.exchange2000.general)
  • Re: Dupator.Swen.A.worm Help
    ... Why not try one of the free online virus scans? ... > I am running Small Business Server 2003. ... > on the OS partition of the machine had grown to be around ... The log file was located ...
    (microsoft.public.windows.server.sbs)
  • Re: Cant connect to the 2003 dc
    ... Mark, have you tried ... please help me verify if the server is running Citrix Metaframe. ... When the users logon to the domain, do you receive any error messages? ... Also please send me an event log file on the client computer that is ...
    (microsoft.public.windows.server.networking)