<code class="lang-php">header("Cache-Control:no-cache,must-revalidate"); $handle = popen('svn --version','r'); $read = stream_get_contents($handle); echo "<pre class="brush:php;toolbar:false">"; printf($read); echo ""; pclose($handle);
代码来源张宴N年前的博客:http://blog.s135.com/post/371/2/1/
这样在浏览器上访问输出的结果OK
svn, version 1.6.11 (r934486) compiled Apr 11 2013, 16:13:51
Copyright (C) 2000-2009 CollabNet. Subversion is open source software,
see http://subversion.tigris.org/ This product includes software
developed by CollabNet (http://www.Collab.Net/).The following repository access (RA) modules are available:
- ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
- ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
- ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
把第二行代码换成popen('svn up --username zmk --password 123456 /home/wwwroot/test/','r');
就不行了(什么都不输出)。
如果把第二行代码换成popen('svn up --username zmk --password 123456 /home/wwwroot/xxx/','r');
这里的/home/wwwroot/xxx
是错误的地址,最终页面会输出Skipped '/home/wwwroot/xxx'
现在这个脚本的用户组和用户是www:www
<code class="lang-php">header("Cache-Control:no-cache,must-revalidate"); $handle = popen('svn --version','r'); $read = stream_get_contents($handle); echo "<pre class="brush:php;toolbar:false">"; printf($read); echo ""; pclose($handle);
代码来源张宴N年前的博客:http://blog.s135.com/post/371/2/1/
这样在浏览器上访问输出的结果OK
svn, version 1.6.11 (r934486) compiled Apr 11 2013, 16:13:51
Copyright (C) 2000-2009 CollabNet. Subversion is open source software,
see http://subversion.tigris.org/ This product includes software
developed by CollabNet (http://www.Collab.Net/).The following repository access (RA) modules are available:
- ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
- ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
- ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
把第二行代码换成popen('svn up --username zmk --password 123456 /home/wwwroot/test/','r');
就不行了(什么都不输出)。
如果把第二行代码换成popen('svn up --username zmk --password 123456 /home/wwwroot/xxx/','r');
这里的/home/wwwroot/xxx
是错误的地址,最终页面会输出Skipped '/home/wwwroot/xxx'
现在这个脚本的用户组和用户是www:www
参考php手册上面的代码,才看出来问题所在。
在下面也自问自答了,这里就不再粘贴复制了,直接链地址吧。
希望对其他遇到同样问题的朋友有所帮助!
http://stackoverflow.com/questions/21870660/access-a-phpscript-through-the-browser-to-execute-the-function-of-popen-som