I’m having a tough time figuring out why the following command is not being executed in perl..
system(". ./setenv.sh");
I’ve tried alternatives such as
ALT 1 = system ".", "./setenv.sh";
ALT 2 = `. ./setenv.sh`;
Not sure what I’m doing wrong..
Any ideas?
EDIT: I figured it out with some of the ideas mentioned here, this is what I did..
system(". ./setenv.sh && <other commands that I required the env for here>");
Thanks!
.andsource(equivalents) arebashinternal commands. The system call tries to find the executable (the first bit before the space) and does not find it (.does not exist as executable as it is a bash internal command).You have to execute bash (or the shell you’re using) directly using system:
However, note that what you’re trying to do, unless
setenv.shhas some side effects, have no effect, as the shell you start to read that environment dies just after executing thesystemline. To establish the environment for your perl program you should be using the%ENVvariable.