首页 > 通过打开url的方式访问php脚本来通过执行popen()函数来执行svn更新

通过打开url的方式访问php脚本来通过执行popen()函数来执行svn更新

header("Cache-Control:no-cache,must-revalidate");
$handle = popen('svn --version','r'); 
$read = stream_get_contents($handle);
echo "<pre>";
printf($read);
echo "</pre>"; 
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'

求linux大神看看

现在这个脚本的用户组和用户是www:www


参考php手册上面的代码,才看出来问题所在。
在下面也自问自答了,这里就不再粘贴复制了,直接链地址吧。
希望对其他遇到同样问题的朋友有所帮助!
http://stackoverflow.com/questions/21870660/access-a-phpscript-through-the-browser-to-execute-the-function-of-popen-som

【热门文章】
【热门文章】