Capture shell_exec output

Discussion in 'PHP' started by SGBoise, Aug 31, 2009.

  1. #1
    Hey guys,

    I need to capture the shell_exec output even if it fails. I'm trying to convert a video using ffmpeg and when I run shell_exec it returns null.

    Anyone know a trick to get the actual text instead of just null? I'm on windows xp if it makes a difference.

    Thanks.
     
    SGBoise, Aug 31, 2009 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Are you using IIS?
     
    ThePHPMaster, Aug 31, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'll give you a tip, always read the comments on php.net

    If that doesn't work, try:

    Or

    http://www.php.net/manual/en/function.shell-exec.php#88052

    Or

    http://www.php.net/manual/en/function.shell-exec.php#67183
     
    premiumscripts, Aug 31, 2009 IP
    SGBoise likes this.
  4. SGBoise

    SGBoise Peon

    Messages:
    647
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm using wamp.

    This worked. Thanks PremiumScripts.

    add '2>&1' to the end of your shell command to have STDERR returned as well as STDOUT.

    $shell_return = shell_exec($shell_command." 2>&1");
     
    SGBoise, Sep 1, 2009 IP