scheme shell
about
download
support
resources
docu
links
 
scsh.net

From: Olin Shivers <shivers@tokyo.cc.gatech.edu>
Newsgroups: comp.lang.scheme.scsh
Subject: Re: taking stdout from a (run (progname))?
Date: 28 Jun 2001 22:43:58 -0400
Organization: College of Computing, Georgia Tech
Message-ID: <k1bsn8ronl.fsf@tokyo.cc.gatech.edu>


Martin Gasbichler wrote:
> 
> >>>>> "Steve" == Steve Wray <stevew@wetafx.co.nz> writes:
> 
> Steve> In perl (yuck) I can run a program and take stdout from it and use
> Steve> that in the rest of the script.
> 
> Steve> maybe like
> Steve> (map (du) (run (ls))
> 
> Steve> which would run du on each file returned by ls...
> Steve> (assuming map works in this thing... mapcar or something maybe?)
> 
> Steve> I'd love to give perl (yuck) the boot...
> 
> Steve> I just printed out the scsh docco and am hopeful...
> Steve> I thought I'd post this Q here to see what useful info you
> Steve> peeps might come up with!
> 
> So, try
> 
> (map (lambda (file) (run/strings (du ,file))) (run/strings (ls)))

Or try
    (run/string (du ,@(run/strings (ls))))
if it's acceptable to have all the reports merged into one big string.

But you shouldn't use ls to generate lists of filenames. Suppose a filename
contained a newline character? And why pay the overhead of running a whole
process just to grab the names of the files in a dir? This is faster *and*
reliable:
    (run/string (du ,@(directory-files)))

Don't run a whole process when you can just call a Scheme function...

I am way behind on scsh posts; will try to catch up this week.
    -Olin

Up