<small id='jZ59G'></small><noframes id='jZ59G'>

  1. <i id='jZ59G'><tr id='jZ59G'><dt id='jZ59G'><q id='jZ59G'><span id='jZ59G'><b id='jZ59G'><form id='jZ59G'><ins id='jZ59G'></ins><ul id='jZ59G'></ul><sub id='jZ59G'></sub></form><legend id='jZ59G'></legend><bdo id='jZ59G'><pre id='jZ59G'><center id='jZ59G'></center></pre></bdo></b><th id='jZ59G'></th></span></q></dt></tr></i><div id='jZ59G'><tfoot id='jZ59G'></tfoot><dl id='jZ59G'><fieldset id='jZ59G'></fieldset></dl></div>
  2. <tfoot id='jZ59G'></tfoot>
    1. <legend id='jZ59G'><style id='jZ59G'><dir id='jZ59G'><q id='jZ59G'></q></dir></style></legend>
        <bdo id='jZ59G'></bdo><ul id='jZ59G'></ul>
    2. PHP exec() 不在输出中返回错误消息

      时间:2023-05-21

    3. <small id='Dz5io'></small><noframes id='Dz5io'>

      • <bdo id='Dz5io'></bdo><ul id='Dz5io'></ul>
          <tbody id='Dz5io'></tbody>
        <legend id='Dz5io'><style id='Dz5io'><dir id='Dz5io'><q id='Dz5io'></q></dir></style></legend>
        • <tfoot id='Dz5io'></tfoot>

                <i id='Dz5io'><tr id='Dz5io'><dt id='Dz5io'><q id='Dz5io'><span id='Dz5io'><b id='Dz5io'><form id='Dz5io'><ins id='Dz5io'></ins><ul id='Dz5io'></ul><sub id='Dz5io'></sub></form><legend id='Dz5io'></legend><bdo id='Dz5io'><pre id='Dz5io'><center id='Dz5io'></center></pre></bdo></b><th id='Dz5io'></th></span></q></dt></tr></i><div id='Dz5io'><tfoot id='Dz5io'></tfoot><dl id='Dz5io'><fieldset id='Dz5io'></fieldset></dl></div>
                本文介绍了PHP exec() 不在输出中返回错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试以 XML 格式获取 svn 命令的某些输出.当我输入有效参数时,输出正常.但是,当我输入错误的密码时,输出不会显示错误消息.这是 PHP 代码:

                I am trying to get certain output for svn command in XML format. Output is ok when I type valid parameters. However, when I type in wrong password, output does not show error message. This is the PHP code:

                exec('/usr/bin/svn --username something --password something --non-interactive log -r HEAD --xml --verbose http://a51.unfuddle.com/svn/a51_activecollab/', $output);
                

                这是我在终端中得到的输出:

                Here is output I get in the terminal:

                <?xml version="1.0"?>
                <log>
                svn: OPTIONS of 'http://a51.unfuddle.com/svn/a51_activecollab': authorization failed: Could not authenticate to server: rejected Basic challenge (http://a51.unfuddle.com)
                

                这是我从带有 var_dump 的 $output 变量得到的输出:

                And here is the output I get from the $output variable with var_dump:

                array(2) {
                [0]=>
                string(21) "<?xml version="1.0"?>"
                [1]=>
                string(5) "<log>"
                }
                

                如您所见,$output 变量不会返回第三行输出,而终端会返回.请帮助我获得与终端相同的输出(我什至尝试使用 shell_exec() 或 system() 方法,但它们返回与 exec() 相同的输出) 如何获得完整输出?提前谢谢你!

                As you can see the $output variable does not return third line of output, where terminal does. Please help me to get the same output as I get in terminal (I even tried with shell_exec() or system() methods but they return the same output as exec()) How do I get full output? Thank you in advance!

                推荐答案

                您也需要捕获 stderr.

                stderr 重定向到 stdout 应该可以解决问题.将 2>&1 附加到您的命令末尾.

                Redirecting stderr to stdout should do the trick. Append 2>&1 to the end of your command.

                例如

                exec("/usr/bin/svn --username something --password something --non-interactive log -r HEAD --xml --verbose http://a51.unfuddle.com/svn/a51_activecollab/ 2>&1", $output);
                

                如果它是一个复杂命令(例如一个带有管道的命令,比如做一个 mysqldump 并将它传递给 gzip 然后重定向到文件 mysqldump ... | gzip > db.sql.gz) 创建一个子shell来捕获整个标准错误并将其重定向到标准输出:

                If it is a complex command (e.g. one with a pipe, like doing a mysqldump and passing it to gzip and then redirecting to file mysqldump ... | gzip > db.sql.gz) create a subshell to capture the overall standard-error and redirect it to standard-output:

                exec('( error_command | cat >/dev/null ) 2>&1', $output)
                #     ^                                ^   ^
                #     `-- sub-shell with the command --´   `-- stderr to $output
                

                这篇关于PHP exec() 不在输出中返回错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 PHP 中获取 Subversion 版本号? 下一篇:SVN网站开发部署解决方案

                相关文章

                最新文章

                <tfoot id='xeOuy'></tfoot>
                <i id='xeOuy'><tr id='xeOuy'><dt id='xeOuy'><q id='xeOuy'><span id='xeOuy'><b id='xeOuy'><form id='xeOuy'><ins id='xeOuy'></ins><ul id='xeOuy'></ul><sub id='xeOuy'></sub></form><legend id='xeOuy'></legend><bdo id='xeOuy'><pre id='xeOuy'><center id='xeOuy'></center></pre></bdo></b><th id='xeOuy'></th></span></q></dt></tr></i><div id='xeOuy'><tfoot id='xeOuy'></tfoot><dl id='xeOuy'><fieldset id='xeOuy'></fieldset></dl></div>

              1. <small id='xeOuy'></small><noframes id='xeOuy'>

                  <legend id='xeOuy'><style id='xeOuy'><dir id='xeOuy'><q id='xeOuy'></q></dir></style></legend>
                      <bdo id='xeOuy'></bdo><ul id='xeOuy'></ul>