scheme shell
about
download
support
resources
docu
links
 
scsh.net

Run Status Streams

Be sure to read the Scsh documentation on `run/collecting' before using this code.

 (define-syntax run/status+streams
   ;; run/status+streams : epf -> integer + listof(string) + listof(string)

;; Run process form EPF and return three values corresponding to the exit ;; status of the process and two lists containing the lines the process ;; sent to STDOUT and STDERR, respectively. (syntax-rules () ((_ epf ...) (receive (status out err) (run/collecting (1 2) epf ...) (let ((stdout-list (port->string-list out)) (stderr-list (port->string-list err))) (close-input-port out) (close-input-port err) (values status stdout-list stderr-list))))))

Sample usage:

 > (run/status+streams (cat /usr/kmshea/mbox))
 ; 3 values
 256
 '()                                                                                                                     
 '("cat: /usr/kmshea/mbox: No such file or directory")
 > (run/status+streams (ls))
 ; 3 values
 0
 '("#foo.scm#" "foo.scm" "foo.scm.~1~")
 '()

See also RunStringsStatus.


RunStatusStreams - raw wiki source | code snippets archive