scsh-expect/doc/chat.doc

48 lines
1.8 KiB
Plaintext

-------------------------------------------------------------------------------
(CHAT <task> <body> ...) -> values syntax
Chat introduces a programmed conversation with a given task. Within
the body expressions, the LOOK-FOR and SEND functions are intended to
either wait for an output of the task, or to send a message to the
task respectively. Furthermore, there are some side-effecting
functions that set some options for this chat.
(look-for* re [on-timeout])
(look-for re [<body> ...])
LOOK-FOR waits until a portion of the task's output matches the given
regular expression. The optional second argument of LOOK-FOR*, or the
body expressions in the LOOK-FOR macro, are executed if the output of
the task does not match within the time specified by the CHAT-TIMEOUT
option (see below).
(send fmt arg ...)
(send/cr fmt arg ...)
SEND simply writes a formatted string to the input-port of the task
(see FORMAT). SEND/CR adds a carriage-return character to the end of
the string.
Side-effecting option setting functions:
(chat-abort <re>)
if this regular expression is matched, the chat call is aborted.
(chat-timeout <nsecs>)
sets the timeout for look-for calls
(chat-monitor <monitor>)
monitor has to be a function taking two arguments (event val),
where event is a symbol, and val a possible value for this
event. The events and the possible type of value are:
- looking-for(re)
- found(match)
- new-input(text)
- sending(text)
- abort(match)
- eof
- timeout
chat can return the following values:
- 'eof
- 'timeout if no timeout-handler was specified in a look-for clause
- <match> in case of an abortion the match of the abort-regexp
- #f if the whole body evaluated normally