While trying to determine the differences between
.bash_profile I notice that
.bashrc is never read, and that
.bash_profile is only read from SSH, but not from PHP. This seems to contradiction to the information in
man bash. Could someone explain to me why this works as it does? The server seems to be a CentOS 5 variant.
local$ ssh user@server Last login: Wed Jan 23 23:21:23 2013 from 22.214.171.124 $ cat .bashrc alias br='echo fromBR' $ cat .bash_profile alias bp='echo fromBP' $ br -bash: br: command not found $ bp fromBP $ cat public_html/bashtest.php <?php echo "hello\n"; echo shell_exec('bp'); echo shell_exec('br'); ?> $ php public_html/bashtest.php hello sh: bp: command not found sh: br: command not found $ wget server/bashtest.php 23:35:13 (759.55 KB/s) - `bashtest.php' saved [7/7] $ cat bashtest.php hello!
So it seems that
.bashrc is never read and
.bash_profile is only read from the CLI (not from PHP either on the user's CLI nor through Apache). Furthermore, through Apache the "command not found" text isn't even returned!
Is this expected behaviour (i.e. am I misinterpreting
man bash) or is something amiss?