[racket] Is there a tcl-expect like module in racket?

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jan 9 12:15:46 EST 2012

20 minutes ago, Neil Van Dyke wrote:
> Not that I know of.  I always handcraft instead.  One example was
> programmatically using a REPL of a statistics system from Racket.  I
> usually use "sync" and block reads into my own buffers, and then
> doing the matching on the buffers, while keeping buffer indexes for
> what's been read.

Most of the usual expect functionality (wait for a pattern, spit out
some text) can probably be done almost directly by just regexp-ing
over the input port.

> An "expect"-like library in Racket would be a fun thing for someone
> to write.  You might be able to do more efficient I/O than most
> languages could, through the power of Racket syntactic extension.

But the IO matching/spitting is the easy part.  The hard parts would
be dealing with things like tty settings, allocating ttys for programs
that need it (frequent problem: ssh passwords), and sending signals
(eg, sending a ^C).  I've recently wrote a testing script for the unix
installer -- and my solution was to write code that simply translates
code into expect, and executes it on the translated code.  Not too
pretty, but very practical.  (You can see it at

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.