This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
`expect-strings' and `with-input-from-port'
- To: guile at sourceware dot cygnus dot com
- Subject: `expect-strings' and `with-input-from-port'
- From: thi <ttn at revel dot glug dot org>
- Date: Wed, 22 Mar 2000 21:57:46 -0800
- Reply-to: ttn at glug dot org
i'm trying to use ice-9/expect.scm and ran across an example posted in
1998 to this list that i'm trying to make work. the example initially
uses `with-input-from-file', which works fine. however, when i replace
that w/ `with-input-from-port', there is no output.
in the snippet appended below, (A) works, (B1) doesn't, but (B2) does.
am i doing something wrong here? (this is w/ recent cvs guile.) can
anyone get (B1) to work?
thi
-------------------------------------------
(use-modules (ice-9 popen))
(use-modules (ice-9 expect))
(set! expect-eof-proc (lambda args
(write-line "found eof!")
(write-line args)
(quit)))
;;; A
(with-input-from-port (open-input-pipe "cat /etc/passwd")
(lambda ()
(let loop ((c (read-char)))
(or (eof-object? c)
(begin
(display c)
(loop (read-char)))))))
;;; B1
(with-input-from-port (open-input-pipe "cat /etc/passwd")
;;; B2
;(with-input-from-file "/etc/passwd"
(lambda ()
(let loop ()
(and (char-ready?)
(begin
(expect-strings
("^.+$"
=> (lambda all
(display all)
(newline))))
(loop))))))
;;;;;;;;;;; snippet ends here