开发者

Shell_exec with git pull?

I am setting up a github account, to work on a small project with some friends. I would like to have my home machine able to do a git pull via php, so that we just have to call this small php file for the machine to be up to date.

As of right now :

<开发者_StackOverflow;?php
$output = shell_exec('git help');
echo "<pre>$output</pre>";
?>

This works perfectly and I get the output, I am in the right directory, so git pull should work just as well, but I get a hanging page, no error, nothing.

Any idea ?

EDIT : A few precisions, the repo is pretty small, around 300K, it takes only a few seconds from the command line. I also tried shell_exec("dir"), and I am in the right directory. I am running the default installation of xampp on Windows 7 x64, if I can be precise enough :)


I suggest exploring set_time_limit() , as well as making sure your git pull does not stop if the user disconnects via ignore_user_abort(). Even running from a gigabit connected server, some repositories just take a while to clone.

Also, check PHP's working directory, and ensure the user running PHP has privileges to write to the repo. If you ran this via CLI and it 'just works', its a good chance that PHP was running without appropriate privileges when accessed via whatever web server you are using.

If you chmod the destionation directory as 777 and it works, there's a very good chance that you need to recompile apache/php for suexec support. Please, don't just leave it as 777 if that is the case :)

Either way, time out and user aborts are still valid considerations, even after you get it working.


So, to answer my own question.

It was in fact a permission problem (thanks tim), from the PHP CLI, the script was working.

The problem was that the service php installation is using some strange permissions. So you/I need to start the PHP server via the command line (or in this case the Xampp control panel).

Now it's working, giving me the "Already up-to-date." answer I was waiting for :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜