[CM] grace 1.1.0

Kjetil S. Matheussen k.s.matheussen at notam02.no
Wed Sep 17 06:55:23 PDT 2008


On Wed, 17 Sep 2008, Heinrich Taube wrote:

> turns out that the current grace 1.1.0 does have access to chicken's  
> (system ) call, ie this will execute the ls command:
> 
> (system "ls /Users/hkt/*")
> 
> the only problem is that any text output by the command is not visible  
> in the console window, im not sure if i can solve this or not i dont  
> know how i could redirect the shells output to the gui window.
> 

The following function works for guile:

(define (get-system-output command)
  (let ((logfilename "/tmp/grace-tempfile"))
    (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)))


Only minor adjustments should be necessary
to make it work in Chicken as well.



More information about the Cmdist mailing list