This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: system call: how to get access to results ?
- To: guile-user at gnu dot org, david at altosw dot be
- Subject: Re: system call: how to get access to results ?
- From: "Dale P. Smith" <dpsm at en dot com>
- Date: Sat, 16 Sep 2000 13:04:50 -0400
- List-Id: <guile-user.gnu.org>
- Organization: Altus Technologies Corporation.
- References: <39C3744D.9FAB4309@altosw.be> <39C39218.9C4CD68E@en.com>
"Dale P. Smith" wrote:
> David Pirotte wrote:
> > The system "displays" the result, but returned value is the exit code
> >
> > How can I "get access" to the expected returned value ?
>
> How about the popen module? Something like (pardon my lame code):
I happier with this:
(use-modules (ice-9 popen))
(define (system-with-output-to-string command)
(let* ((p (open-input-pipe command))
(output (read-delimited "" p)))
(if (eof-object? output)
""
output)))
(define (system-date . rest)
(system-with-output-to-string
(format #f "date ~A" (if (null? rest)
"'+%d-%m-%Y'"
(car rest)))))
(display (system-date))
(display (system-date ""))
--
Dale P. Smith
Altus Technologies Corp.
dsmith@altustech.com
400-746-9000 x309
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user