This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: split vs. scsh


   From: Paul Emsley <paule@chem.gla.ac.uk>
   Date: 29 Jun 2000 22:40:33 +0100

   Is there, then, a guile equivalent of scsh's (run/strings ..)
   (something that captures the output of (system ..) commands).

   If yes, how should I have found out for myself?

i'm not aware of such a procedure.  however, below is a
`shell-command-to-string' which you can munge to taste...

thi


-----------------
RCS/shell-command-to-string.scm,v  -->  standard output
revision 1.3
;;; ID: shell-command-to-string.scm,v 1.3 1999/06/19 19:25:11 ttn Exp

(use-modules (ice-9 popen))

(define (shell-command-to-string cmd)
  (with-output-to-string
    (lambda ()
      (let ((in-port (open-input-pipe cmd)))
	(let loop ((line (read-line in-port 'concat)))
	  (or (eof-object? line)
	      (begin
		(display line)
		(loop (read-line in-port 'concat)))))))))

;;; shell-command-to-string.scm,v1.3 ends here

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]