Problem with exec()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Soper

    Problem with exec()

    I'm using ImageMagic under UNIX via the exec() function. I'm using it to
    ascertain the dimension of JPEGs. The code which is causing problems is
    below, I've used debugging code to try and work out what is going on with
    the results as shown in a browser. I've then taken what appears to be sent
    to the exec() function and copied it straight into a termal on the same
    machine. When running in PHP the $exec_output array seems to be empty but on
    the terminal I'm getting output. Can anyone suggest why this might be so?

    Thanks,
    Geoff Soper

    -----------------------
    Code:
    <snip>
    $identify_cmd = "/home/<username>/ImageMagick/bin/identify -format
    \"%w:%h\" \"JPEG:$input_p ath\"[0]";
    <snip>
    exec ($identify_cmd, $exec_output);
    echo "identify_c md = $identify_cmd<b r>";
    echo 'exec_output = ';
    print_r($exec_o utput);
    echo '<br>';
    list($input_wid th, $input_height) = split(":", $exec_output[0]);
    echo "input_widt h = $input_width<br >";
    echo "input_heig ht = $input_height<b r>";
    exit;
    -----------------------

    -----------------------
    Browser:
    identify_cmd = /home/<username>/ImageMagick/bin/identify -format "%w:%h"
    "JPEG:<path >/Panorama 3.jpg"[0]
    exec_output = Array ( )
    input_width =
    input_height =
    -----------------------

    -----------------------
    Terminal:
    bash-2.05a$ /home/<username>/ImageMagick/bin/identify -format "%w:%h"
    "JPEG:<path >/Panorama 3.jpg"[0]
    6217:2604

    bash-2.05a$
    -----------------------


  • Nathan Gardiner

    #2
    Re: Problem with exec()

    Geoff Soper wrote:[color=blue]
    > I'm using ImageMagic under UNIX via the exec() function. I'm using it
    > to ascertain the dimension of JPEGs. The code which is causing
    > problems is below, I've used debugging code to try and work out what
    > is going on with the results as shown in a browser. I've then taken
    > what appears to be sent to the exec() function and copied it straight
    > into a termal on the same machine. When running in PHP the
    > $exec_output array seems to be empty but on the terminal I'm getting
    > output. Can anyone suggest why this might be so?
    >
    > Thanks,
    > Geoff Soper
    >
    > -----------------------
    > Code:
    > <snip>
    > $identify_cmd = "/home/<username>/ImageMagick/bin/identify -format
    > \"%w:%h\" \"JPEG:$input_p ath\"[0]";
    > <snip>
    > exec ($identify_cmd, $exec_output);
    > echo "identify_c md = $identify_cmd<b r>";
    > echo 'exec_output = ';
    > print_r($exec_o utput);
    > echo '<br>';
    > list($input_wid th, $input_height) = split(":", $exec_output[0]);
    > echo "input_widt h = $input_width<br >";
    > echo "input_heig ht = $input_height<b r>";
    > exit;
    > -----------------------
    >
    > -----------------------
    > Browser:
    > identify_cmd = /home/<username>/ImageMagick/bin/identify -format
    > "%w:%h" "JPEG:<path >/Panorama 3.jpg"[0]
    > exec_output = Array ( )
    > input_width =
    > input_height =
    > -----------------------
    >
    > -----------------------
    > Terminal:
    > bash-2.05a$ /home/<username>/ImageMagick/bin/identify -format "%w:%h"
    > "JPEG:<path >/Panorama 3.jpg"[0]
    > 6217:2604
    >
    > bash-2.05a$
    > -----------------------[/color]

    Geoff,

    ImageMagick may be using STDERR for output instead of STDOUT. Try executing:

    /home/<username>/ImageMagick/bin/identify -format "%w:%h" 1>/dev/null

    and see whether you are still getting output to the console.


    Nathan


    Comment

    Working...