[Larceny-users] reading from a process

Sven.Hartrumpf at FernUni-Hagen.de Sven.Hartrumpf at FernUni-Hagen.de
Sun Dec 30 03:51:22 EST 2007


Hi all.

It seems that I cannot read (anymore?) using read-line (and friends)
from the output generated by 'process'.
Does anybody have a working alternative?

Here is a small example (named readprocess1.scm) showing the problem:

:

(require 'unix)

(define reduce-r (lambda (pred l)
  (let ((l1 (cdr l)))
    (if (null? l1)
      (car l)
      (pred (car l) (reduce-r pred l1))))))

(define (call-with-input-pipe command pred)
  (let* ((results (process (if (string? command)
                             command
                             (reduce-r (lambda (arg result)
                                         (string-append arg " " result))
                                       command))))
         (result (pred (car results))))
    (close-input-port (car results))
    (close-output-port (cadr results))
    (unix/waitpid (caddr results)) ; important in order to remove process
    result))

(call-with-input-pipe '("date" "-I") read-line)


----

> larceny
Larceny v0.96 "Fluoridation" (Dec 23 2007 08:04:15, precise:Linux:unified)
larceny.heap, built on Sun Dec 23 08:15:16 EST 2007

> (load "readprocess1.scm")
Warning: loading source in favor of stale fasl file: .../larceny/lib/Base/string.sch


Error: get-char: argument not a textual input port #<INPUT PORT input descriptor port 7>



Greetings
Sven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ccs.neu.edu/pipermail/larceny-users/attachments/20071230/cc9de593/attachment.bin 


More information about the Larceny-users mailing list