dongluan7821 2014-10-05 11: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 22: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 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿