Extend process IO
This commit is contained in:
parent
57c8b7321d
commit
7fede3fd96
1 changed files with 16 additions and 2 deletions
|
@ -30,6 +30,7 @@
|
||||||
(
|
(
|
||||||
read-lines/no-bom
|
read-lines/no-bom
|
||||||
get-process-output-lines
|
get-process-output-lines
|
||||||
|
get-process-exit+output-lines
|
||||||
process-send/recv
|
process-send/recv
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@
|
||||||
(cdr lines)))))
|
(cdr lines)))))
|
||||||
|
|
||||||
;; Very simple shell command wrapper that returns lines produced by
|
;; Very simple shell command wrapper that returns lines produced by
|
||||||
;; given command. Dangerous - performs no argument escaping!
|
;; given command.
|
||||||
(define (get-process-output-lines cmd . args)
|
(define (get-process-output-lines cmd . args)
|
||||||
(let-values (((stdout stdin pid stderr)
|
(let-values (((stdout stdin pid stderr)
|
||||||
(process* cmd
|
(process* cmd
|
||||||
|
@ -67,9 +68,22 @@
|
||||||
args))))
|
args))))
|
||||||
(close-output-port stdin)
|
(close-output-port stdin)
|
||||||
(let ((result (read-lines stdout)))
|
(let ((result (read-lines stdout)))
|
||||||
(let-values (((a b c) (process-wait pid)))
|
(let-values (((pid exit-ok? exit/signal) (process-wait pid)))
|
||||||
result))))
|
result))))
|
||||||
|
|
||||||
|
;; Very simple shell command wrapper that returns lines produced by
|
||||||
|
;; given command.
|
||||||
|
(define (get-process-exit+output-lines cmd . args)
|
||||||
|
(let-values (((stdout stdin pid stderr)
|
||||||
|
(process* cmd
|
||||||
|
(map (lambda (x)
|
||||||
|
(format "~A" x))
|
||||||
|
args))))
|
||||||
|
(close-output-port stdin)
|
||||||
|
(let ((result (read-lines stdout)))
|
||||||
|
(let-values (((pid exit-ok? exit/signal) (process-wait pid)))
|
||||||
|
(values exit/signal result)))))
|
||||||
|
|
||||||
;; Invokes given command with given arguments, gives it all input
|
;; Invokes given command with given arguments, gives it all input
|
||||||
;; lines and returns the output lines.
|
;; lines and returns the output lines.
|
||||||
(define (process-send/recv cmd args . lines)
|
(define (process-send/recv cmd args . lines)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue