Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: Re: Re: Handling program output in real time

by Anonymous Monk
on Nov 10, 2003 at 08:25 UTC ( #305827=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Handling program output in real time
in thread Handling program output in real time

Not pretty, and perhaps there are better ways, but this may get you started anyway:

#!/usr/bin/perl -w use strict; use IO::Pty; my $pty = new IO::Pty; my $slave = $pty->slave(); my $pid = fork(); die "Couldn't fork: $!" unless defined $pid; if($pid){ # dup STDOUT to Pty and run external program: $pty->close_slave(); open(STDOUT, ">&",$pty)||die $!; system "perl blackbox.pl"; print "\cD"; # send ^d to end } else { # this is your monitoring process $pty->make_slave_controlling_terminal(); print "*$_" while <$slave>; exit; } __END__

Works for me on Linux.


Comment on Re: Re: Re: Re: Re: Handling program output in real time
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305827]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-10-23 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls