http://qs321.pair.com?node_id=99864


in reply to Re: Can you import ENV variables at run time?
in thread Can you import ENV variables at run time?

/bin/bash isn't necessarily everyone's shell and thus any environment variables they set up upon login won't necessarily be set by bash.
$command = sprintf('exec - %s -c env', (getpwuid($>))[8]); $ENV{'HOME'} = (getpwuid($>))[7]; $env = `$command`;
This should run someone's shell as a login shell regardless of what shell it is, and $env will contain the output of env which should be easy to parse.