...

View Full Version : Problem with exec()



gsoper
06-05-2004, 02:11 PM
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$
-----------------------

carl_mcdade
06-05-2004, 03:13 PM
It's too confusing to see just what you are trying to do. The page that has the code that is supposed to be executed is?

firepages
06-06-2004, 10:39 AM
not the answer to your question but why not use getimagesize('/path/to/image') ? it works with or without GD support.

as for image magick , if it works in the terminal it should work via the browser , but if you are getting path related errors (apache/your host may be doing some path translation) try redirecting errors back to PHP and see if they tell you anything .....



<?
exec ($identify_cmd . ' 2>&1 ', $exec_output);
?>

gsoper
06-06-2004, 01:23 PM
Brilliant, that meant I was able to discover it was a memory problem, now I just need to sort that out!

Could you point me in the direction what that cryptic "2>&1" actually does?

Thanks,
Geoff

firepages
06-07-2004, 03:26 AM
Hi, I am not a shell guru , but basically it redirects errors (stderr) to stdout, in your case PHP , more info @ ..
http://www.tldp.org/LDP/abs/html/ioredirintro.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum