[CM] Mixing scheme script with shell script

Kjetil S. Matheussen k.s.matheussen at notam02.no
Fri Sep 19 03:22:27 PDT 2008



On Fri, 19 Sep 2008, Richard Lewis wrote:

> On Thursday 18 September 2008 03:12:12 e deleflie wrote:
>>
>> Does anyone know if it is possible to mix up an SND scheme script
>> with normal shell script calls? (including sharing/passing
>> parameters between them?)
>>
>> something like this: (note:tried the below and it doesn't work)
>>
>> #!/usr/local/bin/snd -b
>> !#
>> (use-modules (ice-9 format))
>> (load "dsp.scm")
>> ...
>> (exit)
>> #!/bin/sh
>> echo $HOME
>>
> The lines beginning #! are called shebang lines and they tell the
> shell which interpreter to invoke to execute the script. At least
> for Bash on my Linux box (and I except the same is true elsewhere),
> it's not possible to have the shell switch interpreters during the
> execution of a script.
>
> One possible solution would be to write one sort of master shell
> script which executes your scheme scripts:
>
> foo.scm:
> #!/usr/local/bin/snd -b
> (use-modules (ice-9 format))
> (load "dsp.scm")
>
> master.sh:
> #!/bin/sh
> ./foo.scm
> echo $HOME
>
> Then run master.sh to execute the whole lot.


Oh, and the other way is to use the "system" function in Guile:

master.scm:
#!/usr/local/bin/snd -b
(use-modules (ice-9 format))
(load "dsp.scm")
...
(system "sh foo.sh")
(exit)

foo.sh:
echo $HOME


Or simply:

master.scm:
#!/usr/local/bin/snd -b
(use-modules (ice-9 format))
(load "dsp.scm")
...
(system "echo $HOME")
(exit)



More information about the Cmdist mailing list