in reply to Expect.pm spawn for exporting evn variables

Most likely, ->spawn() does not spawn a shell. If you change your code to first spawn a shell and then run your shell commands, it might work.

As an alternative, setting elements in %ENV also sets the environment for child processes, so you can do that:

$ENV{ CVSROOT }=':pserver:user11@10.x.x.X:/export/DEMO'; ... $shell_obj = Expect->spawn('echo $CVSROOT') or die "Couldn't start + a program: $!\n";

Note that this only works if echo is an external program and not only a shell builtin.

Replies are listed 'Best First'.
Re^2: Expect.pm spawn for exporting evn variables
by anilfunde (Initiate) on Jun 12, 2015 at 10:42 UTC
    thanks, spawning a shell worked!