This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: system call: how to get access to results ?


"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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]