In said:
Greetings:
We use Modules ( I hate that they chose that name) to load our
shell environment here. So I can do:
mod load myproject
"mod" is an alias to:
/cae/Modules/${MODULE_VERSION}/bin/modulecmd bash load hagrid
And you need the environment from the child shell?
UNIX doesn't work that way, each child process inherits the environment from
the parent. A child process can't change the environment of the parent. (this
is why "cd" is a shell built in) Believe it or not, this is a feature of unix.
(just imagine if a child process could change your path so that the 'cp'
command is now the 'rm' command!)
When you "source" a shell script, you're just telling the shell to run the
script in the current process.
If you're using linux, you can get the environment in a highly non-portable way
using the "proc" filesystem.
To see it try this:
cat /proc/$PID/environ | tr "\0" "\n"
(You need permission..) Of course, the process needs to be running for it
to work...
This isn't portable at all!
Probably your best bet is to have a shell wrapper emit the environment to
stdout and parse the results in perl.
Jamie