dongluan7821 2014-10-05 03:38
浏览 104
已采纳

如何使用exec()从php推送git

Here is my push.bat file

echo "Hello world!"
cd abhishek3/
call git add .
call git commit -m "sadf"
call heroku accounts:set abhishek84 
call git push heroku master

I am able to push to my repository by running push.bat file in cmd

I want to push to my repo from php, tried following snippets but none of them worked for me.

exec("psexec -d push.bat");

Result: PHP page loads indefinitely

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C abhishek3.bat, 0, false);

Result: Page stops loading after a while and nothing works

exec("cmd.exe /c abhishek3.bat")

Result: Page stops loading after a while and nothing works

EDIT: Tried the following snippet but nothing worked.

exec("hstart.exe /NOCONSOLE \"cmd.exe /c \"abhishek3.bat\"\"");

The above snippet runs successfully when run from cmd but when run from php through exec() didn't worked. Download hstart (Hidden Start Binary)

  • 写回答

1条回答 默认 最新

  • doufan9290 2014-10-05 14:48
    关注
    1. check the permissions for the web users are correct (It can access the files and execute git)
    2. check the path for git and any environment variables it may need. You may have to set those environment variables in your script and use absolute paths)
    3. check IIS or apache (whichever you are using) is allowed to execute programs in general and bat files (for example if it is apache, you may have to configure httpd.conf or htaccess depending on your configuration)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 VAE代码如何画混淆矩阵
  • ¥15 求遗传算法GAMS代码
  • ¥15 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部