Hello. I dont' have any previous experience with executing commands through PHP, but I happen to need it done in a project I'm working on. After reading tons, I managed to solve a few common problems for running shell commands in windows.
I tried other commands, to start from the begining... like dir and such. That works like a charm and outputs ok. I even tried an old version of svn.exe and it worked. It said it was too old to work with my repository, but that means it was found, run and params reached it too.
However, when trying with the current Subversion svn.exe, the page keeps loading forever, and Apache process is dead for anything else (I have to switch my tests to 127.0.0.1 / 2 / 3... everytime I try again). Sometimes a process cmd.exe stays open, sometimes it doesn't. I tried exec(), system(), shell_exec(), all with similar results.
Notice the command works right from the command line. What am I missing?
Apache 2.2.x.x
PHP 5.3 (had same problem with previous 5.x version at home)
Subversion 1.6.6
Code:
define('SVN_PATH', 'C:\\Program files\\Subversion\\bin');
define('REPO_PATH', "{$_SERVER['DOCUMENT_ROOT']}/myAppRoot");
define('SVN_USER', 'user');
define('SVN_PASS', 'password');
putenv( "PATH={$_SERVER['PATH']};".SVN_PATH );
$cmd = 'svn update "'.REPO_PATH.'" --username '.SVN_USER.' --password '.SVN_PASS;
$res = exec($cmd, $code);
echo "{$cmd}<br />";
echo "<div>Code: $code</div>";
print_r($res);
However, when trying with the current Subversion svn.exe, the page keeps loading forever, and Apache process is dead for anything else (I have to switch my tests to 127.0.0.1 / 2 / 3... everytime I try again). Sometimes a process cmd.exe stays open, sometimes it doesn't. I tried exec(), system(), shell_exec(), all with similar results.
Notice the command works right from the command line. What am I missing?
Apache 2.2.x.x
PHP 5.3 (had same problem with previous 5.x version at home)
Subversion 1.6.6