By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Problem with exec()

P: n/a
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_path\"[0]";
<snip>
exec ($identify_cmd, $exec_output);
echo "identify_cmd = $identify_cmd<br>";
echo 'exec_output = ';
print_r($exec_output);
echo '<br>';
list($input_width, $input_height) = split(":", $exec_output[0]);
echo "input_width = $input_width<br>";
echo "input_height = $input_height<br>";
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$
-----------------------
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Geoff Soper wrote:
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_path\"[0]";
<snip>
exec ($identify_cmd, $exec_output);
echo "identify_cmd = $identify_cmd<br>";
echo 'exec_output = ';
print_r($exec_output);
echo '<br>';
list($input_width, $input_height) = split(":", $exec_output[0]);
echo "input_width = $input_width<br>";
echo "input_height = $input_height<br>";
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$
-----------------------


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
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.