exec / shell_exec issues

From: Date: Sat, 30 Jul 2005 00:49:01 +0000
Subject: exec / shell_exec issues
Groups: php.general 
Request: Send a blank email to php-general+get-219652@lists.php.net to get a copy of this message
Greetings. I've practically worn my eyeballs out trying to figure out a problem and in desperation am posting here in the hope for familiar eyes to guide me, so thanks in advance. check out this code section: if (file_exists($imagefile)) {
    $execstring = escapeshellarg("/usr/local/bin/mogrify ".$imagefile." -resize 95x72! ");
    }
    else echo ("sorry there was a problem with that file");
// then....2>&1 is assisting the debug $op = shell_exec($execstring.' 2>&1');
    echo $op;
pretty simple - uses the ImageMagick: mogrify. Funny enough it doesn't work. The output is: sh: line 1: /usr/local/bin/mogrify /tmp/phpS1KCen -resize 320x240! : No such file or directory sh: line 1: /usr/local/bin/mogrify /tmp/phpS1KCen -resize 95x72! : No such file or directory beats me how it gets inside the if, if it doesn't exist! I have also tried ImageMagick:convert executable with a generated tempfile using tempnam() and the file is created in /tmp as expected, but is not filled by the convert - it stays empty, fails and doesn't get cleaned up. I cannot give a link to php.ini as its not on a public server. But Safe mode is Off, file size limits are OK as $imagefile can be displayed to the screen prior to the shell_exec call. I also tried using GD instead of ImageMagick and could not get imagecreatetruecolor to work either. OS is OS X on my laptop, entropy build of PHP as "Apache/1.3.29 (Darwin) PHP/5.0.4" I really do not know if this is a PHP, Apache or OS issue. Permissions are not it, I'm sure, and the user is www quite capable of writing into and reading from tmp, so there is no issue there. If anybody can tell me what *anything* about this problem, I'd be greatful. leonski.

« previous php.general (#219652) next »