views:

491

answers:

2

I have the following PHP script:

#!/usr/bin/php
<?php
echo shell_exec(
  "/usr/bin/git clone --bare ".
  "/home/dave/create_project/template_project ".
  "/home/dave/create_project/my_test_project.git"
);

About 7 in 10 times that I run it, git gives the following error:

find: write error: Broken pipe

This error never occurs if I run the equivalent command directly from the shell.

I have already tried:

  • using other PHP execution functions: exec, system, popen;
  • passing the whole command as an argument to bash, i.e., exec('bash -c '.$cmd);

Does anyone have any idea what might be going on?

+1  A: 

It may depend on your exact platform, but findutils has been known to throw that kind of error message before.
On Fedora, that rpm package version 4.2.33-2.fc9 fixed the issue.

VonC
Thanks, I'm using Ubuntu Hardy so the linked issue doesn't directly apply.
D. Evans
A: 

Does PHP throw any errors? Maybe max_execution_time is too low? Mu guess PHP app exites prematurely.

hegemon
No, PHP doesn't throw any errors and I can put code after the shell_exec call and it gets executed so I don't think it's timing out.
D. Evans