4 Replies Latest reply on Dec 13, 2010 6:31 AM by Fernis

    cfexecute output on linux


      Hey everyone, I'm working on doing some stuff with cfexecute via Linux (Ubuntu Server), running ColdFusion 9.  I am having trouble capturing the output of the command that is executed.  Here is the cfexecute line of code:


      <cfexecute name="/usr/local/bin/ffmpeg" arguments="-i '#qGetFiles.directory#/#qGetFiles.name#' 2>&1" outputFile="/home/username/output.txt" timeout="30"></cfexecute>


      I have also tried the following, but just get an empty variable returned:


      <cfexecute name="/usr/local/bin/ffmpeg" arguments="-i '#qGetFiles.directory#/#qGetFiles.name#' 2>&1" variable="mediaInfo" timeout="30"></cfexecute>



      I realize I'm using variables for the input source file path and have verified the paths are all valid.  I verified my CF server is running as root so I know it has the right permissions.  I'm not getting any error message.  I can run the command directly at the CLI with no issues.  I have tried this same code on a Windows server and was able to make it work.  I have also verified that the "2>&1" approach to redirecting the stderr to the output (thanks Ben Forta) works on the Linux OS.


      Anyone out there have experience getting access to the output created by cfexecute on a Linux server?  I'm totally stumped on this one would very much appreciate someone coming to my rescue. 

        • 1. Re: cfexecute output on linux
          matt.glaze Level 1

          A couple more pieces of info on this that I forgot.  The first is that when I run the following line of code...


          <cfexecute name="/usr/local/bin/ffmpeg" arguments="-i '#qGetFiles.directory#/#qGetFiles.name#' 2>&1" outputFile="/home/username/output.txt" timeout="30"></cfexecute>


          ...the output file, "output.txt" is blank.  I then ran the following line of code...


          <cfexecute name="echo" arguments="foo" outputfile="/home/username/testoutput.txt" timeout="30" />


          ...and discovered that my "testoutput.txt" file had the contents of "foo" in it.  So I have now also confirmed that cfexecute is working on my linux server.



          So the last thing I have done to test the execution script on the server itself.  When I run the following line of code at the CLI, the output.txt file is properly updated with the output from the script that I run:



          sudo /usr/local/bin/ffmpeg -i /var/foldername/test2.avi > output.txt 2>&1


          Here's what is now contained in the output.txt file:



          FFmpeg version SVN-r25819, Copyright (c) 2000-2010 the FFmpeg developers

            built on Nov 24 2010 09:29:26 with gcc 4.4.5

            configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab

            libavutil    50.33. 0 / 50.33. 0

            libavcore      0.14. 0 /  0.14. 0

            libavcodec    52.97. 2 / 52.97. 2

            libavformat  52.86. 1 / 52.86. 1

            libavdevice  52. 2. 2 / 52. 2. 2

            libavfilter    1.64. 0 /  1.64. 0

            libswscale    0.12. 0 /  0.12. 0

            libpostproc  51. 2. 0 / 51. 2. 0

          Input #0, avi, from '/var/mediaServer/9/test2.avi':

            Duration: 00:01:00.00, start: 0.000000, bitrate: 29162 kb/s

              Stream #0.0: Video: dvvideo, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

              Stream #0.1: Audio: pcm_s16le, 22050 Hz, 1 channels, s16, 352 kb/s

          At least one output file must be specified



          Now here's the last weird piece to the puzzle; if I run the following line of code:


          <cfexecute name="/usr/local/bin/ffmpeg" arguments=" --help 2>&1" variable="mediaInfo" timeout="30"></cfexecute>

          <cfdump var="#mediaInfo#">


          ...I end up getting ffmpeg's help documentation output to the screen.  So now I know that cfexecute is correctly launching the ffmpeg application.  So now why would sending it a file path suddenly cause it to break?



          Any takers?

          • 2. Re: cfexecute output on linux
            matt.glaze Level 1

            It looks like I just figured this one out.  Thanks to a small post by Ray Camden at the very bottom of the documentation for cfexecute, he mentions about an undocumented attribute called "errorVariable".  So I plugged that in and it worked.  See code below:


            <cfexecute name="/usr/local/bin/ffmpeg" arguments='-i "/var/foldername/test2.avi"' timeout="30" errorVariable="errorInfo"></cfexecute>

            <cfdump var="#errorInfo#"><cfabort>

            • 3. Re: cfexecute output on linux
              Owain North Level 4

              Ooh, that's a cheeky little attribute. As I've only just seen this post (and for posterity's sake), was the issue relevant to CF? Or something different that isn't of concern?



              • 4. Re: cfexecute output on linux
                Fernis Level 3

                On Windows too, ffmpeg.exe output can be found in the error variable rather than in the output variable. I also spent a couple of hours on this one the other week. :-)


                In case the future versions of ffmpeg start returning output to the output variable, it's better to make your ColdFusion code so that it recognizes either one - if the length of the output variable is longer than the error variable, only then use the output variable, etc...