Hello,
I am trying to drive gnuplot from clisp on windows+cygwin (yes I know,
I should just fork over the $500 for Alegro. But, a kid is going to
college). But, I get an error that I cannot figure out where it comes
from.
I define the output stream as
> (defvar *gplot* (ext:make-pipe-io-stream "/bin/gnuplot"))
(I have tried both the unix and windows style paths with same
results. I am not trying the bi-directional declaration, because,
frankly, I don't know what to do with the resulting stream - I am
supposed to get three values, but get only one).
After opening up the stream, the following command sequence
> (format *gplot* "plot sin(x)")
> (finish-output *gplot*)
results in this error:
UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket
closed
[Condition of type SYSTEM::SIMPLE-OS-ERROR]
I have also tried pointing to a nonexistent executable, with the same
result. So it seems that clisp will try to communicate only when I do
the (finish-output *gplot*) command.
I can understand the nomenclature (somewhat), but my understanding of
the internals of unix, windows & cygwin is lacking. I am not sure if
what I am trying to do is even possible with clisp on cygwin (I have
the latest clisp & cygwin).
Thanks,
Mirko
·············@gmail.com writes:
> Hello,
>
> I am trying to drive gnuplot from clisp on windows+cygwin (yes I know,
> I should just fork over the $500 for Alegro. But, a kid is going to
> college). But, I get an error that I cannot figure out where it comes
> from.
>
> I define the output stream as
>
>> (defvar *gplot* (ext:make-pipe-io-stream "/bin/gnuplot"))
>
> (I have tried both the unix and windows style paths with same
> results. I am not trying the bi-directional declaration, because,
> frankly, I don't know what to do with the resulting stream - I am
> supposed to get three values, but get only one).
If you ask for one, you get one.
C/USER[108]> (multiple-value-list (ext:make-pipe-io-stream "/usr/bin/gnuplot"))
(#<IO TWO-WAY-STREAM #<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
#<OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>>
#<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
#<OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>)
C/USER[109]> (mapc 'close *)
(#<CLOSED IO TWO-WAY-STREAM #<CLOSED INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
#<CLOSED OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>>
#<CLOSED INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
#<CLOSED OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>)
C/USER[110]>
> After opening up the stream, the following command sequence
>
>> (format *gplot* "plot sin(x)")
>> (finish-output *gplot*)
>
> results in this error:
> UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket
> closed
> [Condition of type SYSTEM::SIMPLE-OS-ERROR]
>
> I have also tried pointing to a nonexistent executable, with the same
> result. So it seems that clisp will try to communicate only when I do
> the (finish-output *gplot*) command.
I would send a newline as well.
By default, it probably opens the streams in buffered mode. Hence the
need for a FINISH-OUTPUT.
> I can understand the nomenclature (somewhat), but my understanding of
> the internals of unix, windows & cygwin is lacking. I am not sure if
> what I am trying to do is even possible with clisp on cygwin (I have
> the latest clisp & cygwin).
The following works on Linux.
C/USER[106]> (flet ((eat (stream)
(loop
:while (listen stream)
:do (princ (read-char-no-hang stream nil nil))
:finally (finish-output))))
(with-open-stream (io (EXT:MAKE-PIPE-IO-STREAM "/usr/bin/gnuplot" :buffered t))
(eat io) (format io "plot ksin(x)~%") (finish-output io)
(eat io) (format io "plot kos(x)~%") (finish-output io)
(eat io) (format io "plot sin(x/3)+sin(x)/3~%") (finish-output io)
(sleep 4) (eat io) (format io "quit~%") (finish-output io)
(eat io)))
line 0: undefined function: ksin
line 0: undefined function: kos
NIL
C/USER[107]>
It should probably work identically on cygwin (modulo the path to gnuplot).
Notice that gnuplot seems to detect that it runs with a PTY instead of
interactively with a true terminal, and outputs only error messages.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The mighty hunter
Returns with gifts of plump birds,
Your foot just squashed one.
On Aug 17, 3:27 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> ·············@gmail.com writes:
> > Hello,
>
> > I am trying to drive gnuplot from clisp on windows+cygwin (yes I know,
> > I should just fork over the $500 for Alegro. But, a kid is going to
> > college). But, I get an error that I cannot figure out where it comes
> > from.
>
> > I define the output stream as
>
> >> (defvar *gplot* (ext:make-pipe-io-stream "/bin/gnuplot"))
>
> > (I have tried both the unix and windows style paths with same
> > results. I am not trying the bi-directional declaration, because,
> > frankly, I don't know what to do with the resulting stream - I am
> > supposed to get three values, but get only one).
>
> If you ask for one, you get one.
>
> C/USER[108]> (multiple-value-list (ext:make-pipe-io-stream "/usr/bin/gnuplot"))
> (#<IO TWO-WAY-STREAM #<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
> #<OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>>
> #<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
> #<OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>)
> C/USER[109]> (mapc 'close *)
> (#<CLOSED IO TWO-WAY-STREAM #<CLOSED INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
> #<CLOSED OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>>
> #<CLOSED INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER 6196>
> #<CLOSED OUTPUT UNBUFFERED PIPE-OUTPUT-STREAM CHARACTER 6196>)
> C/USER[110]>
>
duh (somehow, I got used to automatic printout of all values at once)
> > After opening up the stream, the following command sequence
>
> >> (format *gplot* "plot sin(x)")
> >> (finish-output *gplot*)
>
> > results in this error:
> > UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket
> > closed
> > [Condition of type SYSTEM::SIMPLE-OS-ERROR]
>
> > I have also tried pointing to a nonexistent executable, with the same
> > result. So it seems that clisp will try to communicate only when I do
> > the (finish-output *gplot*) command.
>
> I would send a newline as well.
>
> By default, it probably opens the streams in buffered mode. Hence the
> need for a FINISH-OUTPUT.
>
> > I can understand the nomenclature (somewhat), but my understanding of
> > the internals of unix, windows & cygwin is lacking. I am not sure if
> > what I am trying to do is even possible with clisp on cygwin (I have
> > the latest clisp & cygwin).
>
> The following works on Linux.
>
> C/USER[106]> (flet ((eat (stream)
> (loop
> :while (listen stream)
> :do (princ (read-char-no-hang stream nil nil))
> :finally (finish-output))))
> (with-open-stream (io (EXT:MAKE-PIPE-IO-STREAM "/usr/bin/gnuplot" :buffered t))
> (eat io) (format io "plot ksin(x)~%") (finish-output io)
> (eat io) (format io "plot kos(x)~%") (finish-output io)
> (eat io) (format io "plot sin(x/3)+sin(x)/3~%") (finish-output io)
> (sleep 4) (eat io) (format io "quit~%") (finish-output io)
> (eat io)))
> line 0: undefined function: ksin
>
> line 0: undefined function: kos
>
> NIL
> C/USER[107]>
>
Thanks for the example code Pacal.
Unfortunately, I was getting the same errors with your setup, so I
broke it into little pieces. I was getting the broken pipe error
after the (finish-output stream) form.
I tried to debug it by checking the socket status. I get an error:
CL-USER> (setf *foo* (ext:make-pipe-io-stream "/usr/bin/
gnuplot" :buffered t))
#<IO TWO-WAY-STREAM #<INPUT BUFFERED PIPE-INPUT-STREAM CHARACTER
22360>
#<OUTPUT BUFFERED PIPE-OUTPUT-STREAM CHARACTER 22360>>
CL-USER> (socket:socket-status *foo*)
:ERROR
1
CL-USER>
I think that at this point I will take it up with the clisp folks as
they seem to be doing the cygwin port as well.
Thanks,
Mirko
Mirko Vukovic writes:
> I am trying to drive gnuplot from clisp on windows+cygwin
> I define the output stream as
>
> > (defvar *gplot* (ext:make-pipe-io-stream "/bin/gnuplot"))
> After opening up the stream, the following command sequence
>
> > (format *gplot* "plot sin(x)")
> > (finish-output *gplot*)
>
> results in this error:
> UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket
> closed
> [Condition of type SYSTEM::SIMPLE-OS-ERROR]
>
The following works with my five months old cygwin/clisp/gnuplot on xp
(defun plot (l)
"Intention : View a list of numbers with gnuplot.
Effect : Plots $ (i, l_i) \forall i $ (via file tmp_gnuplot.dat).
Format : Numbers may be written with an exponent preceded by letter
e, E, d, D, q, or Q; L, S also accepted. Lengths ??"
#+clisp
(with-open-stream
(s (ext:make-pipe-output-stream "gnuplot -persist"))
(format
s
"set style data linespoints
plot '~a'
"
(list2file l "tmp_gnuplot.dat"))
(finish-output s)))
The code from Pascal Bourguignon works as well.
> So it seems that clisp will try to communicate only when I do
> the (finish-output *gplot*) command.
>
With previous releases of cygwin/clisp no flushing was necessary.
--
Take it Easy Don't Hurry Be Happy
Thierry
�������o�o��������o�o��������o�o��������o�o��������o�o�������
On Aug 18, 12:15 am, Thierry Pirot <····@thierrypirot.net> wrote:
> Mirko Vukovic writes:
> > I am trying to drive gnuplot from clisp on windows+cygwin
> > I define the output stream as
>
> > > (defvar *gplot* (ext:make-pipe-io-stream "/bin/gnuplot"))
> > After opening up the stream, the following command sequence
>
> > > (format *gplot* "plot sin(x)")
> > > (finish-output *gplot*)
>
> > results in this error:
> > UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket
> > closed
> > [Condition of type SYSTEM::SIMPLE-OS-ERROR]
>
> The following works with my five months old cygwin/clisp/gnuplot on xp
>
> (defun plot (l)
> "Intention : View a list of numbers with gnuplot.
> Effect : Plots $ (i, l_i) \forall i $ (via file tmp_gnuplot.dat).
> Format : Numbers may be written with an exponent preceded by letter
> e, E, d, D, q, or Q; L, S also accepted. Lengths ??"
> #+clisp
> (with-open-stream
> (s (ext:make-pipe-output-stream "gnuplot -persist"))
> (format
> s
> "set style data linespoints
> plot '~a'
> "
> (list2file l "tmp_gnuplot.dat"))
> (finish-output s)))
>
> The code from Pascal Bourguignon works as well.
>
> > So it seems that clisp will try to communicate only when I do
> > the (finish-output *gplot*) command.
>
> With previous releases of cygwin/clisp no flushing was necessary.
> --
> Take it Easy Don't Hurry Be Happy
>
> Thierry
>
> °¨¨¨¨°ºo§oº°¨¨¨¨°ºo§oº°¨¨¨¨°ºo§oº°¨¨¨¨°ºo§oº°¨¨¨¨°ºo§oº°¨¨¨¨°
Thank Thierry,
I had the same problem with you code as well. Something seems broken
with my clisp/cygwin (don't know which) ffi setup. For example, I
cannot link to the gsl (gnu scientific library) dll's, while others
have reported success. I'll check with the clisp/cygwin folks.
Thank you both for your help,
Mirko