douyi0902 2010-03-26 11:43
浏览 192
已采纳

带git pull的Shell_exec?

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 :

<?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 :)

  • 写回答

2条回答 默认 最新

  • doubaoguo7469 2010-03-26 11:48
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型