Environment partitioning in ksh

Hi

I am not sure if this is possible.

What I need to do is run multiple instances of a script in parallel with different output paths from a single driver script, ie,

driver.ksh:

#!/bin/ksh

num=1
sed s/DUMMY/${num}/g script.template > script.ksh
./script.ksh &
num=2
sed s/DUMMY/${num}/g script.template > script.ksh
./script.ksh &

script.template:

#!/bin/ksh

num=DUMMY
export out_path=/home/${num}
etc...

The variable $num is set by the driver script and used by script.ksh to create an environment variable which defines the output path, among other things.

I cannot change the name of the environment variable or the fact that it IS an environment variable.

What I'd like to know is if it is possible to run each instance of script.ksh within its own separate environment, with it's own definition of $out_path.

Cheers

Overwriting a shell script while it is executed by the shell will produce random nonsense. Either choose different scriptnames, like script1.ksh, script2.ksh or put them into different directories.

or use arguments

./script.ksh 1 &
./script.ksh 2 &

and parameters

num=$1

The environment is private - there is no conflict.

hergp sorry, this is an idealised example. I should have shown the script names to be different, as they are in the actual code.

Thanks MadeInGermany, this works for me.