in reply to Re^2: Calling a shell script after changing directory
in thread Calling a shell script after changing directory

I am actually executing a shell script which sets environment variables

That is not going to work. The scope of environment variables is not global but limited to the process where they are set and subprocesses forked from it which inherit them.

In your code, system launches a shell that starts a new shell for executing test1.sh. Any environment variable set in the script just lives until the second shell terminates.

A possible way to work around that is to dump the variables from the shell before it terminates. For instance:

# untested; my $set_env = `cd $dir && source test1.sh && perl -MData::Dumper -e 'p +rint Dump \\\%ENV'` and die; print $set_env;

Replies are listed 'Best First'.
Re^4: Calling a shell script after changing directory
by Gouravhere (Initiate) on May 11, 2016 at 08:39 UTC

    Thanks Salva. there seems to be an issue with the shell script which is setting the environment variables. I am calling a shell file siebenv.sh which resides in the siebel server. if you want to execute it manually then you just need to fire the following command.

     . ./siebenv.sh Now when you do that from perl, it is not happening. I guess there is nothing to do from Perl. But still I am lost here :)
      Show us the code you are using and also tell us what do you mean by it is not happening exactly.
        Actually there is a huge limitation in accessing the siebenv.sh from any other system (Perl in this case). So I just did a work around where I have executed the siebenv.sh after moving to the desired directory and then did the associated activities inside that shell script only just because if i stop the processing in shell and return to Perl, that don't execute the associated activities as the directory was not moved physically from where the Perl script resides.