tags:

views:

426

answers:

3

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

+1  A: 

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

wallyk
It works very well on every system so far, the code is actually part of a commercial application. Ommiting redirection output doesn't affect anything. The issue appears only on my local computer.
Oliver
I can't edit my comment: I have tried `system()` before, but it returns an empty string as output and `int(139)` as return value, pretty much the same as `exec()`.
Oliver
A: 

A couple of questions:

  1. What is the exact php you're using for the "strip out the authentication" code?

  2. Does your username or password contain any "funny" characters that could confuse the shell or php? (quotes, backticks, etc.)

svec
Oliver
Again, note that this an isolated issue that appears only on one system so far. The same code works smooth on many different web servers.
Oliver
This could be a server config issue, perhaps you should try the question at serverfault.com.
svec
+1  A: 

I also had similar problems after moving my PHP app from a Windows server to UNIX. More specifically, several of the svn command I was running via shell_exec() returned null output.

In my case, the problem was related to the UNIX permissions of the .svn directory and contained files. My svn checkout was owned by a standard user account. But when the PHP script (via the Apache process) ran the shell_exec() command it did so using a different account (nobody:nobody) which did not have write-access to the .svn directory and important files therein (such as the .lock file).

The solution for me was to use the chown command to make the .svn directories/files owned by the same group as the Apache process (chown -R :nobody .svn).

Clint Harris
I am not checking out files - just using "svn info" on a repository and I keep getting no output (although I get the output if I copy-paste the command into terminal). Setting custom config directory doesn't do any good, so I'd give up the problem with saving/reading svn's config data. Simply, there's not output from svn info, while "svn --version", for example, returns the output just fine :-/
Oliver