[Haskell-cafe] Writing an 'expect'-like program with
graham.fawcett at gmail.com
Thu May 1 16:40:13 EDT 2008
I would like to communicate with an external, line-oriented process,
which takes a sequence of one-line commands, each returning an
arbitrary number of lines, and waits for another command after each
response. So, something like:
sendCmd :: (Handle, Handle) -> String -> IO [String]
main = do
handles <- connectToExternalProcess
sendCmd handles "do something"
resp <- sendCmd "get results" -- needs strict I/O, before "quit"?
mapM_ putStrLn resp
I've tried using runInteractiveCommand, and several combinations of
hFlush, hWaitForInput, etc., but I can't find a combination that
I know this is a sketchy description, but can anyone offer some sample
code, or point me toward a program that has similar behaviour?
More information about the Haskell-Cafe