[slime-devel] Re: scripting via swank
Alan Caulkins
fatman at maxint.net
Sat Jan 27 20:48:01 UTC 2007
On Fri, Jan 26, 2007 at 12:31:07PM +0100, Helmut Eller wrote:
> * Gábor Melis [2007-01-25 19:09+0100] writes:
>
> > Ahoj
> >
> > Suppose there is a long running lisp image with a swank server and I
> > want to connect to it from shell scripts and evaluate lisp forms in an
> > environment where *standard-output*, *standard-input* and
> > *error-output* are bound to streams that correspond to stdout, stdin
> > and stderr of the shell script.
> >
> > The only idea I had was to pass the pid of the shell script to the lisp
> > and bind *standard-output* to
> > (open "/proc/<pid-of-shell-script/fd/0" ...) which should work on
> > linux.
I don't know that there is a good way to connect the shell script to
the actual standard I/O in the Lisp image, but you might be able to get
halfway there. You want a utility called nc (aka Netcat) that relays
data between its stdin/stdout and sockets. It was designed to allow
shell scripts to use streams to interface with network daemons and such.
example:
$ echo -n "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80 > file.html
You'd have to listen on a socket in the Lisp, but once that connection
is made, you could use stream I/O. Netcat works with UNIX domain sockets,
so you wouldn't have to worry about TCP connections from other hosts.
http://netcat.sourceforge.net/
man page: http://www.openbsd.org/cgi-bin/man.cgi?query=nc
Another slightly less flexible possibility is Netpipes:
http://web.purplefrog.com/~thoth/netpipes/netpipes.html
-A
--
Maxint Consulting
Linux: The ultimate video game.
More information about the slime-devel
mailing list