WAMP - PHP shell_exec() problem
-
06-09-2019 - |
Question
I'm using WAMP as a server, and I have a need to execute svn, which can be found in my Windows directory: C:/Program Files/Subversion/bin/
The problem, is that when I launch the php program from the server, it won't produce output. It works from the command line, which makes me think this is a permissions problem with WAMP. However after giving it unlimited power, it still won't execute svn commands unless I call it from the command line.
I've tried calling it with the full path to svn, and it's regular path. Other commands like "dir" work fine.
To clarify my question: How can I execute svn from php through WAMP?
Solution
use free svn classes instead, they don't require svn module: http://www.phpclasses.org/browse/package/3427.ht http://code.google.com/p/phpsvnclient/
OTHER TIPS
PHP has a whole bunch of functions which deal explicitly with svn repositories and doesn't require you to use any system()-type functions.
Since you said you cannot use the various svn functions, try the following:
<?php
$cmd = 'set PATH';
echo '<pre>' , shell_exec( $cmd ) , '</pre>';
?>
See what that returns (look for the PATH environment variable). See what PATH contains.
You may have to add the Subversion folder to your PATH:
<?php
$cmd = 'set PATH=%PATH%;"C:\Program Files\Subversion\bin\"; svn up';
shell_exec( $cmd );
?>
Hopefully, setting the PATH will solve your problem.
I found this problem too and can solve this problem, make sure you use username and password (if need)
eg. svn update "\my\project\" --username [myusername] --password [mypassword]
If not, no output and svn still wait for you enter that.
P.S. When I log on and run svn on cmd, it not request username and password but when I run on PHP you need it. Hopefully, it will solve your problem.