[CM] grace 1.1.0
Heinrich Taube
taube at uiuc.edu
Wed Sep 17 07:44:28 PDT 2008
> The following function works for guile:
> Only minor adjustments should be necessary
> to make it work in Chicken as well.
indeed! here is the twiddled version:
(define (get-system-output command)
(let ((logfilename "/tmp/grace-tempfile"))
(system (string-append command " > " logfilename))
(let* ((ret "")
(eol (list->string (list #\newline)))
(fd (open-input-file logfilename ))
(line (read-line fd)))
(do ()
((eof-object? line) #f)
(set! ret (string-append ret line eol))
(set! line (read-line fd)))
(close-input-port fd)
(system (string-append "rm " logfilename))
ret)))
so to get a shell command's output to appear as regular printout in
the Console window you would do:
(print (get-system-output "ls *.*"))
ill add this as (shell ...) in the next release, eg something like
(define (shell cmd)
(print (get-system-output cmd))
(values))
thanks much kjetil!
--rick
More information about the Cmdist
mailing list