MiklerGM has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

My task is:
Analyze stdout of some app, and if needed write to stdin I write a script with full logic, and it works.
But one of the apps did't flush stdout if stdout is a fifo. Only if stdout is to tty

I want to fake tty somehow.
google said, that i need to use 'Expect'
or run my target app through 'script -c []'

is there are any possibility to do something like

$stdout->isAtty(1);

i do not want to rewrite all code to using an expect, i think is a big kludge to my needs



Thanks

Replies are listed 'Best First'.
Re: IPC::Open3 emulate tty mode on stdout handle (pty)
by Anonymous Monk on Jul 01, 2013 at 07:12 UTC
    IO::Pty?

    OTOH its kind of hard to find an app stupid enough to only flush for true ttys

      I tried something: It stacs on the same place as if i do a regulag fh created by open3.
      After stack i recieve many lines in one time not as they appear :(
      my $pty = new IO::Pty; my $read = $pty->slave; my ($write,$err); $ppid = open3($write, $read,$err, "$bin_dir/$bin $args $pidfile"); print "=>" . $_ while(<$read>);
      And this shows nothing:
      my $pty = new IO::Pty; local *READ = $pty->slave; my ($write,$err); $ppid = open3($write, ">&READ",$err, "$bin_dir/$bin $args $pidfile"); print "=>" . $_ while(<READ>);