dpn68721 2017-02-04 02:46
浏览 331

从PHP脚本中运行git命令

I have a file upload form and after the file uploads I want to push the files up to GitHub by running:

git add .
git commit -m "some message"
git push origin master

How do I go about this? I've seen examples of using exec() but that makes me nervous.

shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git add -A');
shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git commit -m "something 1"');
shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git push origin master');

Those commands don't error but don't work either. Do I need to grant access to the apache user to use the ssh key?

  • 写回答

3条回答

  • dsfs21312 2017-02-04 03:10
    关注

    i guess is permission problems, you can use exec() , and get the error info by $output

    exec($your_command.' 2>&1', $output, $return_var);
    var_dump($output);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类