简体   繁体   中英

Running SVN commands from PHP using exec, shell_exec, or system

I have a very simple piece of code which should theoretically get me a svn list from php

<?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);
?>

Both these methods return following errors

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 )

I am able to run either of the svn commands from command line just fine, I also have ssh-key based authentication setup to talk to the svn.server.com

All I want to do is get a list of folders from the trunk. our svn is only setup for svn+ssh access.

Any ideas?

Your answer is here:

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

  1. run a chmod 777 on .svn directory
  2. run an svn update via command line
  3. call script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM