vote up 1 vote down star

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

flag

50% accept rate

3 Answers

vote up 1 vote down

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

link|flag
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 Nov 25 at 23:48
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 Nov 26 at 0:05
vote up 1 vote down

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).

link|flag
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 Jan 1 at 3:14
vote up 0 vote down

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.)

link|flag
1. "strip out" = if I remove the authentication = if I try without supplying username and password = "/opt/subversion/bin/svn info --non-interactive <REPO_URL> 2>&1 2. username and password contain only letters and numbers – Oliver Nov 30 at 16:19
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 Nov 30 at 16:21
This could be a server config issue, perhaps you should try the question at serverfault.com. – svec Dec 2 at 16:11

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.