|
From: | Kjetil S. Matheussen |
Subject: | Re: X11 bindings and shell bindings |
Date: | Thu, 18 Sep 2008 18:54:09 +0200 (CEST) |
"Ishan Arora": > And is there a procedure to > synchronously run a shell code and return the output as a String. Thanks. > Should do: (use-modules (ice-9 rdelim)) (define (get-system-output command) (let ((logfilename (tmpnam))) (system (string-append command " > " logfilename)) (let* ((ret "") (fd (open-file logfilename "r")) (line (read-line fd))) (while (not (eof-object? line)) (set! ret (string-append ret line)) (set! line (read-line fd))) (close fd) (system (string-append "rm " logfilename)) ret)))
[Prev in Thread] | Current Thread | [Next in Thread] |