Hi, There might be a better solution, but this is the function I've been using to do this:
(define (get-system-output command) (let ((logfilename "/tmp/logtemp")) (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))) (this is for guile though, not s7, but you get the idea) On Wed, Nov 25, 2015 at 4:38 PM, JV <[email protected]> wrote: > system prints the output of the command. > I cannot save the output with: > > (define sv (system ("ls")) > > On Wed, Nov 25, 2015 at 8:02 AM, <[email protected]> wrote: > >> system is normally included in s7 in Linux -- try >> (help system) or (system "ls -la s7.c" #t). If your >> version of s7 was built with the compiler flag >> WITH_SYSTEM_EXTRAS set to 0, you can still get at the >> c library's system function via libc.scm, but >> hopefully that isn't necessary. >> >> >> > > > -- > Joseph Vijay > > _______________________________________________ > Cmdist mailing list > [email protected] > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > >
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
