• <bdo id='s9A1d'></bdo><ul id='s9A1d'></ul>
    <tfoot id='s9A1d'></tfoot>
  1. <legend id='s9A1d'><style id='s9A1d'><dir id='s9A1d'><q id='s9A1d'></q></dir></style></legend>
  2. <small id='s9A1d'></small><noframes id='s9A1d'>

    1. <i id='s9A1d'><tr id='s9A1d'><dt id='s9A1d'><q id='s9A1d'><span id='s9A1d'><b id='s9A1d'><form id='s9A1d'><ins id='s9A1d'></ins><ul id='s9A1d'></ul><sub id='s9A1d'></sub></form><legend id='s9A1d'></legend><bdo id='s9A1d'><pre id='s9A1d'><center id='s9A1d'></center></pre></bdo></b><th id='s9A1d'></th></span></q></dt></tr></i><div id='s9A1d'><tfoot id='s9A1d'></tfoot><dl id='s9A1d'><fieldset id='s9A1d'></fieldset></dl></div>
    2. PHP - 如何让 Shell 错误回显到屏幕上

      时间:2023-09-20

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

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

              <i id='PDIX4'><tr id='PDIX4'><dt id='PDIX4'><q id='PDIX4'><span id='PDIX4'><b id='PDIX4'><form id='PDIX4'><ins id='PDIX4'></ins><ul id='PDIX4'></ul><sub id='PDIX4'></sub></form><legend id='PDIX4'></legend><bdo id='PDIX4'><pre id='PDIX4'><center id='PDIX4'></center></pre></bdo></b><th id='PDIX4'></th></span></q></dt></tr></i><div id='PDIX4'><tfoot id='PDIX4'></tfoot><dl id='PDIX4'><fieldset id='PDIX4'></fieldset></dl></div>
                <tbody id='PDIX4'></tbody>
                本文介绍了PHP - 如何让 Shell 错误回显到屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在第一次使用 shell_exec().我正在尝试使用 ffmpeg shell 脚本在我的服务器上转换一些视频文件.

                I am in the process of using shell_exec() for the first time. I am trying to convert some video files on my server using the ffmpeg shell script.

                当我在浏览器中执行以下代码时,它返回NULL:

                When I the below code in the browser, it returns NULL:

                var_dump(shell_exec("ffmpeg -i /var/www/html/sitedomain/httpdocs/tmp/ebev1177.mp4"));
                

                但是,当我在终端中运行等效代码时:

                However when I run the equivalent code in my terminal:

                <代码>>ffmpeg -i/var/www/html/sitedomain/httpdocs/tmp/ebev1177.mp4

                我得到了一大堆有用的信息,这些信息以错误结束必须至少指定一个输出文件"

                I get back a whole load of useful information which ends in an error "At least one output file must be specified"

                为什么没有将此信息传递回我的 PHP 脚本以便我可以将其回显?

                Why is this info not being passed back to my PHP script so I can echo it out?

                推荐答案

                错误数据从目标程序的STDERR流中输出.您可以通过将 2>&1 附加到命令,通过 shell_exec() 的正常返回字符串访问错误数据,该命令将重定向 STDERRSTDOUT,您当前看到的流:

                The error data is output from the target program's STDERR stream. You can get access to the error data through the normal returned string from shell_exec() by appending 2>&1 to the command, which will redirect STDERR to STDOUT, the stream that you are currently seeing:

                var_dump(shell_exec("ffmpeg -i /var/www/html/sitedomain/httpdocs/tmp/ebev1177.mp4 2>&1"));
                

                您可能还想看看 proc_open() 这将允许您获得将 STDINSTDOUTSTDERR 作为三个单独的流访问,这可以对目标程序进行更细粒度的控制,以及您如何处理输入和输出到它,包括将它们中的任何一个和所有直接重定向到日志文件(如果需要).但请注意,这是一个复杂得多的机制,存在许多陷阱和绊倒危险.

                You may also want to take a look at proc_open() which will allow you to get access to STDIN, STDOUT and STDERR as three individual streams, which can afford much finer grained control over the target program and exactly how you handle the input and output to it, including redirecting any and all of them directly to a log file if so desired. Be aware though that this is a much more complex mechanism with many pitfalls and tripping hazards.

                可以在此处找到有关标准流的更多信息.

                More information on the standard streams can be found here.

                这篇关于PHP - 如何让 Shell 错误回显到屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:ffmpeg MAMP“dyld:库未加载"错误 下一篇:FFMpeg - 为视频文件创建缩略图

                相关文章

                最新文章

                  <legend id='Fzdhd'><style id='Fzdhd'><dir id='Fzdhd'><q id='Fzdhd'></q></dir></style></legend>

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

                    <tfoot id='Fzdhd'></tfoot>

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