chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Adding (system->string) somewhere


From: Elf
Subject: Re: [Chicken-users] Adding (system->string) somewhere
Date: Mon, 14 Jan 2008 14:55:34 -0800 (PST)


how about

(define (system->string . args)
    (string-chomp (with-input-from-pipe (string-join args " ") read-all)))

this is assuming that you meant that you want to construct a single command
from a list of strings.  if you wanted each string to be a separate command
it could look like:

(define (system->string . args)
    (apply conc
           (map
               (lambda (x)
                   (with-input-from-pipe x read-all))
               args)))

or if you wanted a list of cmds, where each cmd was either a string or a list
of string components:

(define (system->string . args)
    (apply conc
           (map
               (lambda (x)
                   (with-input-from-pipe
                       (if (string? x)
                           x
                           (string-join x " "))
                       read-all))
               args)))


granted, none of these do errorchecking or whatnot, but that should be trivial
to add.

-elf


On Mon, 14 Jan 2008, Zbigniew wrote:

Ozzi <address@hidden> writes:
I am using the following code, which just takes a single string:
(define (system->string cmd)
  (string-chomp (with-input-from-pipe cmd read-all)))

On Jan 14, 2008 1:45 PM, Kon Lovett <address@hidden> wrote:
See also http://galinha.ucpel.tche.br/Unit%20utils#system

system and system* do not capture the command output.


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]