Advertisement
Guest User

Untitled

a guest
Jul 7th, 2018
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.66 KB | None | 0 0
  1. (define-module (io run)
  2.   #:use-module (io files)
  3.   #:use-module (ice-9 popen)
  4.   #:use-module (rnrs io ports)
  5.   #:use-module (ice-9 receive)
  6.   #:export (open-process
  7.             run/str
  8.             run/lines
  9.             run/retval))
  10.  
  11. (define open-process (@@ (ice-9 popen) open-process))
  12.  
  13. (define (run/str command)
  14.   (receive (in out _) (open-process OPEN_READ "sh" "-c" command)
  15.     (let ([res (get-string-all in)])
  16.       (close-port in)
  17.       res)))
  18.  
  19. (define (run/lines command)
  20.   (receive (in out _) (open-process OPEN_READ "sh" "-c" command)
  21.     (let ([res (port->list in get-line)])
  22.       (close-port in)
  23.       res)))
  24. (define run/retval system)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement