我正在使用exec()在php中编写一些函数来查询svn。
The commands exec("svn list ".$myurl) works.现在,我尝试使用checkout命令在svn存储库上获取路径。 当我将命令“svn checkout http://core.wordress.org/tags/2.9.2/ last-version”直接放在控制台中时,它可以工作。
但是,当我使用exec()从php脚本执行此操作时,如下所示:
exec("svn checkout ".$myurl, $dir)它不起作用。
你有个主意吗?
I'm writing some functions in php using exec() to interrogate a svn.
The commands exec("svn list ".$myurl) works.Now, I try to get a path on a svn repository with the checkout command. When I put the command "svn checkout http://core.wordress.org/tags/2.9.2/ last-version" directly in the console, it works.
But when I do this from a php script using exec(), like this :
exec("svn checkout ".$myurl, $dir)it doesn't work.
Have you an idea ??
最满意答案
这可能有多种原因。
不允许在其下运行的用户PHP写入您要签入的目录
SVN存储库需要为PHP运行的用户缓存的登录凭据
SVN签出过程开始,但需要一些额外的输入,如可怕的“你想接受此证书”与未签名的证书。
尝试在命令中添加2>&1将stderr重定向到stdout,然后查看$dir 。 还可以使用$return_var参数来执行exec() 。
正如Jacob指出的那样,总是使用escapeshellargs()作为命令参数。
This can have a variety of reasons.
The user PHP runs under is not allowed to write into the directory you want to check out into
The SVN repository requires login credentials that are not cached for the user PHP runs under
The SVN checkout process starts, but requires some additional input like the dreaded "Do you want to accept this certificate" with unsigned certificates.
Try adding 2>&1 to the command to redirect stderr to stdout, and take a look at $dir. Also make use of the $return_var parameter to exec().
And as Jacob pointed out, always use escapeshellargs() for your command arguments.
更多推荐
发布评论