[Users] vztcl runscript and keep the same env variables?

Sam Trenholme strenholme.usenet at gmail.com
Sun Sep 25 12:56:47 EDT 2011


> In a simple bash script named "test.sh", I used to call another shell
> script "part1.sh" keeping the same Env variables like this:
>
> $head -n 1 test.sh
> . ./part1.sh
>
> Now, I would like to do the same with vzctl runscript:
>
> $head -n 1 test.sh
> vzctl runscript 1110 part1.sh

echo '#!/bin/bash' > tmp.sh
env | awk -F= '{print $1 "=\"" $2 "\""}' >> tmp.sh
cat part1.sh >> tmp.sh
vzctl runscript 1110 tmp.sh
rm tmp.sh

Escaping quotes in environmental variables or using mktemp is left as
an exercise to the reader.

- Sam


More information about the Users mailing list