Possible Duplicate:
Why does an SSH remote command get fewer environment variables then when run manually?
Running on Mac OS X 10.8.2
I'm running a perl script through SSH, in the perl script I query environment variables using $ENV{MY_VAR_NAME} and it works fine when run locally. But through SSH, all environment variables become unset.
I also tried to run
system("source ~/.bash_profile");
at the beginning of my script to no avail.
Any tips?
EDIT:
Rephrasing my question.
I have machine A and B. I ran my perl on machine B, trying to get the environment variables on B and it worked. Then I ssh from A to B running the same script, i.e., using this code
ssh user@B perl myscript.pl
This time the environment variables on B are all blank.
Any tips?
UPDATE:
I found that running the above script, ~/.bashrc on Machine B was invoked, but after setting environment variables in ~/.bashrc, run the above command again and still I don't see any environment variables.
Also, if my perl script contains only
echo $ENV{PATH}
Then I get
/usr/bin:/bin:/usr/sbin:/sbin