Hi All,<div><br></div><div>I am trying to send commands from Racket to Maxima (algebra system).</div><div>Here is a normal interaction with Maxima in the terminal:</div><div><br></div><div><div>soegaard$ /Applications/Maxima.app/Contents/Resources/maxima.sh </div>
<div>Maxima 5.25.1 <a href="http://maxima.sourceforge.net">http://maxima.sourceforge.net</a></div><div>using Lisp SBCL 1.0.47</div><div>Distributed under the GNU Public License. See the file COPYING.</div><div>Dedicated to the memory of William Schelter.</div>
<div>The function bug_report() provides bug reporting information.</div><div>(%i1) 1+2;</div><div>(%o1) 3</div><div>(%i2) </div></div><div><br></div><div>After displaying the welcome message, Maxima display the prompt "(%i1) ".</div>
<div>The I entered 1+2;<enter>.</div><div>Maxima then evaluated the expression and printed the line beginning with (%o1).</div><div><br></div><div>Maxima has an option -s <port> that makes Maxima listen on a give port.</div>
<div>I have used this to write the following:</div><div><br></div><div><div>#lang racket</div><div>(require racket/tcp)</div><div>(define PORT 8082)</div><div><br></div><div>(let ([listener (tcp-listen PORT 1 #t)])</div><div>
(process (format "/Applications/Maxima.app/Contents/Resources/maxima.sh -s ~a >/dev/null" PORT))</div><div> (let-values ([(in out) (tcp-accept listener)]) </div><div> (for ([i (in-range 6)]) ; there are 6 lines in the welcome message</div>
<div> (display (read-line in))</div><div> (newline))</div><div> (display "prompt:\n")</div><div> (write (read in)) ; this displays the prompt (%i1)</div><div> (newline)</div><div> (write (read-char in)) ; eat whitespace</div>
<div><div> (newline)</div></div><div> (display "Prompt read correctly.\n")</div><div> (display "Sending command to Maxima.\n")</div><div> (display "1+2;\n" out) (flush-output out)</div>
<div> (display "Wait, before readin result.\n")</div><div> (sleep 1)</div><div> (display "Read and print the result one character at a time.\n")</div><div> (for ([i (in-range 6)])</div><div>
(display (peek-char in)) (display "."))))</div><div><br></div><div>This gives the following output when run in DrRacket:</div><div><br></div><div>pid=15314</div><div>Maxima 5.25.1 <a href="http://maxima.sourceforge.net">http://maxima.sourceforge.net</a></div>
<div>using Lisp SBCL 1.0.47</div><div>Distributed under the GNU Public License. See the file COPYING.</div><div>Dedicated to the memory of William Schelter.</div><div>The function bug_report() provides bug reporting information.</div>
<div>prompt:</div><div>(%i1)</div><div>#\space</div><div>Prompt read correctly.</div><div>Sending command to Maxima.</div><div>Wait, before readin result.</div><div>Read and print the result one character at a time.</div>
<div> </div></div><div>(and then nothing is printed)</div><div><br></div><div>My problem is that I don't get any output back.</div><div>I have a feeling I am missing something obvious - but what?</div><div><br></div>
<div>-- <br>Jens Axel Søgaard<br><br>
</div>