This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: `expect-strings' and `with-input-from-port'


> 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)))))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]