首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP更新- TortoiseSVN

PHP更新- TortoiseSVN
EN

Stack Overflow用户
提问于 2013-06-30 08:32:38
回答 1查看 1.2K关注 0票数 2

新代码:

代码语言:javascript
复制
<?php
exec('"C:\Program Files\TortoiseSVN\bin\svn.exe" update "c:\wamp\www\project"');

这将导致无限循环,不返回任何结果。我做错了什么?

==编辑==

在Windows上,我试图使用PHP更新一个项目。我在使用命令行时遇到了问题:我想要视觉反馈(在冲突情况下很重要),所以我不想从后台进程开始。这个是可能的吗?

到目前为止,我的代码是:

代码语言:javascript
复制
<?php
$todo = "cd \"C:\\Program Files\\TortoiseSVN\\bin\\\"";
$todo2 = "START TortoiseProc.exe /command:update /path:\"C:\\wamp\\www\\project\\\" /closeonend:0";

 pclose(popen($todo, "r"));  
 pclose(popen($todo2, "r"));  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-06 15:27:11

我将删除exec并使用proc_open (参见http://php.net/manual/en/function.proc-open.php)。

下面是我迅速提出的一个例子,它应该适用于您:

代码语言:javascript
复制
<?php
// setup pipes that you'll use
$descriptorspec = array(
    0 => array("pipe", "r"),    // stdin
    1 => array("pipe", "w"),    // stdout
    2 => array("pipe", "w")     // stderr
);

// call your process
$process = proc_open('"C:\Program Files\TortoiseSVN\bin\svn.exe" update "c:\wamp\www\project"',
                     $descriptorspec,
                     $pipes);

// if process is called, pipe data to variables which can later be processed.
if(is_resource($process)) 
{
    $stdin = stream_get_contents($pipes[0]);
    $stdout = stream_get_contents($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[0]);  
    fclose($pipes[1]);  
    fclose($pipes[2]);
    $return_value = proc_close($process);   
}

// Now it's up to you what you want to do with the data you've got.
// Remember that this is merely an example, you'll probably want to 
// modify the output handling to your own likings...

header('Content-Type: text/plain; charset=UTF-8');  

// check if there was an error, if not - dump the data
if($return_value === -1)    
{
    echo('The termination status of the process indicates an error.'."\r\n");
}

echo('---------------------------------'."\r\n".'STDIN contains:'."\r\n");
echo($stdin);
echo('---------------------------------'."\r\n".'STDOUTcontains:'."\r\n");
echo($stdout);
echo('---------------------------------'."\r\n".'STDERR contains:'."\r\n");
echo($stderr);

?>

撇开:

线

代码语言:javascript
复制
// call your process
$process = proc_open('"C:\Program Files\TortoiseSVN\bin\svn.exe" update "c:\wamp\www\project"',
                     $descriptorspec,
                     $pipes);

也可以像这样逃出来

代码语言:javascript
复制
// call your process
$process = proc_open("\"C:\\Program Files\\TortoiseSVN\\bin\\svn.exe\" update \"c:\\wamp\\www\\project\"",
                     $descriptorspec,
                     $pipes);

它可能解决或不可能解决某些系统上的问题,这些系统在符号中带有单括号(')和空格()。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17388589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档