This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: `expect-strings' and `with-input-from-port'
- To: ttn at glug dot org
- Subject: Re: `expect-strings' and `with-input-from-port'
- From: Gary Houston <ghouston at arglist dot com>
- Date: 23 Mar 2000 21:18:38 -0000
- CC: guile at sourceware dot cygnus dot com
- References: <200003230557.VAA15874@revel.glug.org>
> Date: Wed, 22 Mar 2000 21:57:46 -0800
> From: thi <ttn@revel.glug.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?
>
Consider this:
(char-ready? (open-input-pipe "cat /etc/passwd"))
=> #f
since the program will take a while to start up.
Here's a similar example which does work:
(use-modules (ice-9 popen))
(use-modules (ice-9 expect))
(set! expect-eof-proc (lambda args
(write-line "found eof!")
#f))
(with-input-from-port (open-input-pipe "cat /etc/passwd")
(lambda ()
(let loop ()
(if (expect-strings
("^.+$"
=> (lambda all
(display all)
(newline)
all)))
(loop)))))