[racket] Embedding multiline shell scipts

From: Jukka Tuominen (jukka.tuominen at finndesign.fi)
Date: Sun Feb 6 08:12:49 EST 2011

Thanks Manfred and Thomas,

I'm just about to try these. One more requirement that I forget to mention
is that it should also be possible to handle "expect" type of "automated
conversations". You can pass several independent commands with system/output
without problem, but I had difficulties in figuring out how to log into
different machines, change the user etc. where you need to pass answers
interactively or otherwise move between various modes (which expect can
automate).

There is possibly a more schemy way of doing this, but I'm trying to find an
easily adaptable way to reuse existing system scripts and turn them into
scheme primitives for higher abstractions.

br, jukka


> -----Original Message-----
> From: users-bounces at racket-lang.org
> [mailto:users-bounces at racket-lang.org]On Behalf Of Manfred Lotz
> Sent: 06 February 2011 12:51
> To: users at racket-lang.org
> Subject: Re: [racket] Embedding multiline shell scipts
>
>
> 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
>
>
>
>
>
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.