Great, thanks Thomas! br, jukka
> -----Original Message----- > From: thomas.ch...@googlemail.com [mailto:thomas.ch...@googlemail.com]On > Behalf Of Thomas Chust > Sent: 06 February 2011 22:37 > To: Jukka Tuominen > Cc: users@racket-lang.org > Subject: Re: [racket] Embedding multiline shell scipts > > > 2011/2/6 Jukka Tuominen <jukka.tuomi...@finndesign.fi>: > > [...] > > I slightly modified the Manfred's code to capture the output > > [...] > > Hello, > > the code seems somewhat more complicated than necessary to me and it > lacks some cleanup and error handling. I would suggest to use the > available utilities from racket/port to simplify the I/O code and the > control procedure returned from process to at least wait for the > external process to finish. > > A module like this should do the trick: > > #lang racket/base > (require > racket/match > racket/port > racket/system) > > (define (shell command) > (match-let* ([(list stdout stdin pid stderr control) (process > command)] > [lines (port->lines (merge-input stdout stderr))]) > (close-output-port stdin) > (close-input-port stdout) > (close-input-port stderr) > (control 'wait) > (case (control 'status) > [(done-ok) > lines] > [(done-error) > (error > 'shell "~e failed with exit code ~a" > command (control 'exit-code))]))) > > (provide > (all-defined-out)) > > Ciao, > Thomas > > > -- > When C++ is your hammer, every problem looks like your thumb. _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users