Using bash shell from within PHP

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2011-01-15T20:36:23Z Indexed on 2011/01/15 20:53 UTC
Read the original article Hit count: 318

Filed under:
|
|

Hi everyone,

In my terminal window (using Max OS X) my shell is bash. However when I run a command in PHP via shell_exec or backtick operators I see that PHP is using the Bourne Shell (sh). Here's an example of what I'm seeing:

From within my terminal window:

$ echo $0
- bash

Also if I call php as follows:

$ php -r "echo shell_exec('echo $0');"
-bash

However, if I create a script called test.php with the following:

<?php echo shell_exec('echo $0'); ?>

And then run test php I get the following:

$ php test.php
sh

I'm wanting to use the bash shell when calling shell_exec - why is it choosing the Bourne shell and can I force it to use bash?

Thanks!

Dan

© Stack Overflow or respective owner

Related posts about php

Related posts about bash