PHP: Using SVN subcommands and options in exec() causes “segmentation fault”

execPHPsvn

There is something that drives me nuts these days since I cannot continue my work on a project. I've switched to another computer and can't get PHP and svn executable to work together nicely 🙂

$output = "";  
$value = "";  
exec("/opt/subversion/bin/svn info --username something --password something --non-interactive <REPO_URL> 2>&1", $output, $value);  

var_dump($output);  
var_dump($value);

Output:

array(0) { } int(139)

139 = Segmentation fault, but it doesn't help much since I have no clue what could be causing it. Running the same piece of code directly in terminal works like a charm, but it's an issue if PHP tries to do the same via exec().

If I strip out the authentication, I get the correct output (request for authentication).

Chmod-ing Subversion executable to 777 doesn't seem to make any difference.

If it's of any use, it's Mac OS X 10.5.8, PHP 5.2.11 and Apache 2.2.13

Best Answer

exec() doesn't work with the < and > redirection operators: those are functions of a shell. The easy workaround is to call system() instead.

Related Topic