[racket] Embedding multiline shell scipts

From: Thomas Chust (chust at web.de)
Date: Sun Feb 6 09:19:14 EST 2011

2011/2/6 Jukka Tuominen <jukka.tuominen at finndesign.fi>:
> [...]
> One more requirement that I forget to mention is that it should also
> be possible to handle "expect" type of "automated conversations".
> [...]

Hello,

if you want I/O redirection, you should, for example, use the
procedure process [1] instead of system.

> [...]
> You can pass several independent commands with system/output without
> problem, but I had difficulties in figuring out how to log into
> different machines, change the user etc.
> [...]

Executing remote commands can for be done by passing the command to an
SSH client, for example, instead of directly handing it to the local
shell.

> [...]
> where you need to pass answers interactively or otherwise move
> between various modes (which expect can automate).
> [...]

Interactive communication with a shell or other program, whether local
or remote doesn't really matter, can be somewhat more complicated,
though. I don't know of any existing Scheme library that simplifies
the communication with an interactive subprocess via an input and an
output port in a similar way as expect does. It is certainly possible
to create equivalent code in Racket and the fact that regular
expression matching can be directly applied to input ports is
certainly helpful for such an endeavour. But there are some potential
pitfalls like commands behaving entirely differently depending on
whether their I/O file descriptors are connected to a
(pseudo-)terminal or some other communications channel or output
containing terminal control escape sequences.

Ciao,
Thomas


[1] http://docs.racket-lang.org/reference/subprocess.html?q=process#(def._((lib._racket/system..rkt)._process))


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.