Christopher Browne cbbrowne at ca.afilias.info
Wed Oct 31 06:35:31 PDT 2007
Dominik Klein <dk at in-telegence.net> writes:
> (how?) is it possible to pass parameters to a slonik script?
>
> Like in a bash script
>
> #!/bin/bash
> echo $1
>
> and then "./script.sh test" would output "test".

Slonik is intentionally a *very* limited language, and it doesn't
itself support variables like that.

But nothing prevents you from using a shell script to generate the
slonik script, and having Bash do the parameter processing.

Thus, something like:

#!/bin/bash
PARM=$1
slonik <<EOF
include <my_standard_preamble.slonik>
### preamble kept out so I don't have to worry about initializing it
echo 'Display parm 1 - ${PARM}';
EOF

Parameter handling was in Bash's hands in that script.

You want a loop, you can have a loop:

#!/bin/bash
PARM=$1

for i in 10 9 8 7 6 5 4 3 2 1; do
  COUNTDOWN="${COUNTDOWN}
  echo 'counting down - ${i}';
"
done

slonik <<EOF
include <my_standard_preamble.slonik>
### preamble kept out so I don't have to worry about initializing it
echo 'Display parm 1 - ${PARM}';
${COUNTDOWN}
EOF

But don't hold your breath on having Slonik enhanced to do this sort
of thing...
-- 
let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;;
http://cbbrowne.com/info/linuxxian.html
"Being really good at C++ is  like being really good at using rocks to
sharpen sticks."  -- Thant Tessman


More information about the Slony1-general mailing list