Re: Pipeline never becomes readable
- From: koffee <lukefei@xxxxxxxxx>
- Date: Thu, 26 Jun 2008 14:22:05 -0700 (PDT)
On Jun 26, 4:57 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On Jun 26, 10:43 pm, wimaxj <wim...@xxxxxxxxx> wrote:
Hi,
I want to interact with gnuplot in Tcl in the following way:
====================
set a [open "|gnuplot" RDWR];
fconfigure $a -blocking 0;
fileevent $a readable [list show $a];
proc show {ch} {
puts "This is show";
puts [read $ch];
}
# no matter how, the pipeline never becomes readable
puts $a {plot "data.file" using 1:2};
puts $a {help}; # it should print help document
puts $a {some nosense}; # it should print error msg.
=====================
No matter what input I gave, there's no feedback from gnuplot. The
proc. "show" never be called. Anything wrong here?
First, you should make sure your [puts] to the pipe are flushed. For
this, the simplest is to [fconfigure -buffering line] since
interaction with gnuplot is line-oriented.
Second, just in case something interesting is written to stderr by
gnuplot, better route it transparently to tclsh's stderr:
set a [open "|gnuplot 2>@ stderr" RDWR];
Third, in your fileevent you may want to read in line-oriented mode
too with [gets]:
proc show {chan} {
if {[gets $chan line] >= 0} {
puts SHOW:$line
} elseif {[eof $chan]} {
close $chan
}
}
(example stolen to Donal, should normally make it to the manpage
quickly)
-Alex
Hi,
Thank you very much for the suggestion. I forgot to mention that I did
flush the channel whenever I wrote to it. This doesn't help.
But [open "|gnuplot 2>@ stderr" RDWR] really make the feedback from
gnuplot printed on the screen. But it's not from the proc. "show",
because no prefix "SHOW:" showing.
So, the problem remains.
.
- Follow-Ups:
- Re: Pipeline never becomes readable
- From: Alexandre Ferrieux
- Re: Pipeline never becomes readable
- References:
- Pipeline never becomes readable
- From: wimaxj
- Re: Pipeline never becomes readable
- From: Alexandre Ferrieux
- Pipeline never becomes readable
- Prev by Date: How to make TCL to show the error stack in interpreted mode?
- Next by Date: Re: Pipeline never becomes readable
- Previous by thread: Re: Pipeline never becomes readable
- Next by thread: Re: Pipeline never becomes readable
- Index(es):
Relevant Pages
|