in reply to Unix environment variables for exec process

Probably not related to your problem, but I noticed:

$envscript 2>&1 > expect.out;
Assuming you want to fold stdout/stderr into file expect.out, you've got the order wrong. It should be written as:
$envscript > expect.out 2>&1;
To see what I mean, run the following commands:
perl -le "print STDERR q{to-stderr};print STDOUT q{to-stdout}" 2>&1 >f +.tmp perl -le "print STDERR q{to-stderr};print STDOUT q{to-stdout}" >f.tmp +2>&1
and note the difference.