How to push git to php using exec ()

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 can push to my repository by running push.bat file in cmd

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

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

      

Result: PHP page loads unlimited

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

      

Result: the page stops loading after a while and nothing works

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

      

Result: the 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 did not work when run from php via exec (). Download hstart (Hidden start)

+3


source to share


1 answer


  • Check permissions for web users (it can access files and execute git)
  • check the path for git and any environment variables you might need. You may need to set these environment variables in your script and use absolute paths)
  • check IIS or apache (whichever you are using) is allowed to run programs in general and bat files (for example if it is apache, you might have to tweak httpd.conf or htaccess depending on your configuration).


+1


source







All Articles