Hello Stefan Schor, in a previous mail you wrote:
> Hallo,
>
> the window will freeze, because when I read from the pipe, and the other
> process has not been
> written data into it, the reading will block until data is available.
Ooops - sorry, you are right on that point!
In my case this wasn't a problem because the program would
usually produce lots and lots of output (actually the output
from a compiler, on a quite large base of source code), and
the $root->update() would get called on each line of output...
> The other programm write the data sometimes only after some seconds, which
> will block the
> reading during this time (and with the reading also the ui).
>
> Best regards,
> Stefan Schor
Absolutely true, I'm afraid.
Sorry for the wrong info.
Good luck anyway!
Cheers,
Steffen
> -----Original Message-----
> From: Steffen Beyer [mailto:sb@xxxxxxxxxxxxxxx]
> Sent: Dienstag, 9. März 2004 20:15
> To: Stefan Schor
> Cc: 'Paul Johnson'; ptk@xxxxxxxxxxxxxxxxxx
> Subject: Re: FW: Perl und externe Programme
>
>
> Hello Stefan Schor, in a previous mail you wrote:
>
> > Hallo,
> >
> > thanks a lot. I solved the problem, but the sollution at the bottom
> > wouldn't work for me. The external programm thaks some time (more than
> > 20 seconds), so the ui would freeze.
>
> It doesn't freeze if you send your window (the one containing the Tk::Text
> or Tk::ROText widget) an "update" after each insert, for example.
>
> $text->insert('end', $line);
> $root->update();
>
> > My first idea was die fileevent way, but after a while I know,
> > that the windows port of perl doesn't support this feature.
> > The problem is the select implementation of windows, which doesn't work
> > on pipes.
> >
> > I found a other way, which a polling mechanism... (intervals of
> > 250ms...)
> >
> > Thanks a lot
> > Stefan
> >
> >
> >
> > -----Original Message-----
> > From: Paul Johnson [mailto:pjcj@xxxxxxxx] On Behalf Of Paul Johnson
> > Sent: Montag, 8. März 2004 21:57
> > To: Steffen Beyer
> > Cc: Stefan Schor; ptk@xxxxxxxxxxxxxxxxxx
> > Subject: Re: FW: Perl und externe Programme
> >
> >
> > On Sun, Mar 07, 2004 at 09:01:56AM +0100, Steffen Beyer wrote:
> >
> > > Hello Stefan Schor, in a previous mail you wrote:
> > >
> > > > -----Original Message-----
> > > > From: Stefan Schor [mailto:Stefan.Schor@xxxxxx]
> > > > Sent: Sonntag, 7. März 2004 03:09
> > > > To: 'Steffen.Beyer@xxxxxxxxxxxx'
> > > > Subject: Perl und externe Programme
> > > >
> > > > Hallo,
> > > >
> > > > ich habe von Ihnen in Perl-Newsgroups ein Posting gesehen. Es ging
> > > > darum, aus Perl herraus ein externes Programm zu starten und dessen
> > > > Ausgaben in einem Perl/Tk Programm anzuzeigen.
> > > >
> > > > Koennen Sie mir dazu was sagen?
> > > > Geht es?
> > > > Wie geht es?
> > > >
> > > > Ich habe schon mehrere Sachen ausprobiert, aber bis jetzt noch
> > > > keinen Erfolg gehabt.
> > >
> > > Ganz leicht:
> > >
> > > #!perl -w
> > >
> > > use strict;
> > >
> > > use Symbol;
> > >
> > > my $FH = gensym;
> > > my $CMD ="whatever";
> > > my $line;
> > >
> > > unless (open($FH, "$CMD 2>&1 |"))
> > > {
> > > die "$0: unable to spawn external command <$CMD>: $! ($?)\n"; }
> > > while (defined ($line = <$FH>)) {
> > > # do something with output from command,
> > > # for example:
> > > # $text->insert('end', $line);
> > > }
> > > unless (close($FH))
> > > {
> > > die "$0: unable to complete external command <$CMD>: $! ($?)\n";
> > > # Beware that on Windows, $? == -1 must not necessarily mean
> > > # a failure, it just means "returncode not available", and
> > > # you don't know what returncode the command actually exited with
> > > }
> > >
> > > > Mit freundlichen Gruessen,
> > > >
> > > > Stefan Schor
> > > >
> > >
> > > Hope this helps. :-)
> >
> > This should work fine when the external program doesn't take long to
> > complete, but will cause the gui to freeze while the external program
> > is running. If that is a problem you might want to check out
> > Tk::fileevent.
> >
> > Gruss,
> >
> > --
> > Paul Johnson - paul@xxxxxxxx
> > http://www.pjcj.net
>
> --
> Steffen Beyer <sb@xxxxxxxxxxxxxxx>
> http://www.engelschall.com/u/sb/whoami/ (Who am I)
> http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
> http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
--
Steffen Beyer <sb@xxxxxxxxxxxxxxx>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx
|