OpenVZ Forum


Home » Mailing lists » Users » vztcl runscript and keep the same env variables?
vztcl runscript and keep the same env variables? [message #43567] Sun, 25 September 2011 11:40 Go to next message
Benjamin Henrion is currently offline  Benjamin Henrion
Messages: 51
Registered: February 2011
Member
From: *parallels.com
Hi,

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

How do I do that?

Best,

--
Benjamin Henrion <bhenrion at ffii.org>
FFII Brussels - +32-484-566109 - +32-2-4148403
"In July 2005, after several failed attempts to legalise software
patents in Europe, the patent establishment changed its strategy.
Instead of explicitly seeking to sanction the patentability of
software, they are now seeking to create a central European patent
court, which would establish and enforce patentability rules in their
favor, without any possibility of correction by competing courts or
democratically elected legislators."
Re: vztcl runscript and keep the same env variables? [message #43568 is a reply to message #43567] Sun, 25 September 2011 16:56 Go to previous messageGo to next message
samiam is currently offline  samiam
Messages: 15
Registered: July 2011
Junior Member

From: *parallels.com
> 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
Re: vztcl runscript and keep the same env variables? [message #43569 is a reply to message #43568] Sun, 25 September 2011 17:30 Go to previous message
samiam is currently offline  samiam
Messages: 15
Registered: July 2011
Junior Member

From: *parallels.com
> env | awk -F= '{print "export " $1 "=\"" $2 "\""}' >> tmp.sh

Works even better :)
Previous Topic: Run truecrypt in a container?
Next Topic: /var/lock/subsys directory missing on openvz debian squeeze
Goto Forum:
  


Current Time: Fri Aug 17 03:56:12 GMT 2018