[racket] Embedding multiline shell scipts

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Sun Feb 6 05:51:24 EST 2011

On Sun, 6 Feb 2011 11:26:40 +0200
"Jukka Tuominen"
<jukka.tuominen at finndesign.fi> wrote:

> 
> Hi all,
> 
> I'm trying to embed multiline shell scripts within a scheme function,
> but I'm not quite sure how to do it.
> 
> With multiline shell scripts I mean the scripts that are usually
> saved as separate files containing for example:
> 
> ---
> #!/bin/sh
> 
> while home
> do
> ...
> done

The following should work, although there might be a better way
doing it:


(define shebang "#! /bin/sh\n")

(define script-body "
 
while home
  do
  ...
done
")

(define script (string-append shebang script-body ))


(call-with-output-file "testscript.sh" #:mode 'text #:exists 'replace
  (lambda (out)
     (fprintf out "~a" script)))



-- 
Manfred









Posted on the users mailing list.