使用exec,shell_exec或system从PHP运行SVN命令

时间:2012-08-20 15:44:23

标签: php svn

我有一段非常简单的代码,理论上应该从php

获取一个svn列表
<?php
print_r("Method 1<br/>");
$x = exec("/usr/bin/svn list svn+ssh://svn.server.com/path/to/trunk/ 2>&1", $o, $m);
print_r($o);

print_r("<br/><br/><br/>");

print_r("Method 2<br/>");
$x = exec("/usr/bin/svn list --username user --password pass svn+ssh://svn.server.com/path/to/trunk/ 2>&1", $o, $m);
print_r($o);
?>

这两种方法都会返回以下错误

Method 1
Array ( [0] => svn: warning: Can't open file '/root/.subversion/servers': Permission denied [1] => No protocol specified [2] => [3] => (gnome-ssh-askpass:6062): Gtk-WARNING **: cannot open display: :0.0 [4] => svn: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file. [5] => svn: Network connection closed unexpectedly ) 


Method 2
Array ( [0] => svn: warning: Can't open file '/root/.subversion/servers': Permission denied [1] => No protocol specified [2] => [3] => (gnome-ssh-askpass:6062): Gtk-WARNING **: cannot open display: :0.0 [4] => svn: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file. [5] => svn: Network connection closed unexpectedly [6] => svn: warning: Can't open file '/root/.subversion/servers': Permission denied [7] => No protocol specified [8] => [9] => (gnome-ssh-askpass:6066): Gtk-WARNING **: cannot open display: :0.0 [10] => svn: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file. [11] => svn: Network connection closed unexpectedly )

我可以从命令行运行任何一个svn命令就好了,我也有基于ssh-key的身份验证设置来与svn.server.com交谈

我想要做的就是从主干获取一个文件夹列表。我们的svn只为svn + ssh访问设置。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

你的答案在这里:

Calling an svn update from a php script via a browser is not working

  1. 在.svn目录
  2. 上运行chmod 777
  3. 通过命令行运行svn update
  4. 调用脚本