system exec shell_exec passthru backtick ??????
Posted: Wed Feb 06, 2008 1:41 pm
Ok, so here is what I am trying to do. I have this old Perl script which I cannot get rid of because it is part of a large content management system. It has an image uploader which currently uploads just about anything. I want to take advantage of OSX's "sips" command to resample the image and generate thumbnails. This is just a unix command, so I should be able to use one of the functions in the title above. However it doesn't work.
In Perl, there are also system() and bactick operators. So, in the Perl code, right after the image is uploaded, I add a call to a php script:
$path is the path to the image
$thumb_path is where I want to write the thumbnail file to
Now, the php script looks like this:
All the extra stuff there is just me troubleshooting - I write to a text file, the command that I am passing to exec() so I can make sure it comes out right (which it does, everytime).
So, the problem is that the exec() fails. I have checked permissions and they are wide open. I even modifed the command to be like this (to try and force the command to be executed as root user):
sudo -u root -S /usr/bin/sips --resampleWidth 60 $path --out $thumb_path < /etc/root.secret
In Perl, there are also system() and bactick operators. So, in the Perl code, right after the image is uploaded, I add a call to a php script:
Code: Select all
`/usr/bin/php /Users/php/acuweb_helpers/create_thumb.php $path $thumb_path`;$thumb_path is where I want to write the thumbnail file to
Now, the php script looks like this:
Code: Select all
<?php
$path = $argv[1];
$thumb_path = $argv[2];
exec("/usr/bin/sips --resampleWidth 60 $path --out $thumb_path", $output, $ret);
$stuff = implode(',',$output)."\n";
$string = "/usr/bin/sips --resampleWidth 60 $path --out $thumb_path"." ,returns: ".$ret."\n\n";
$handle = fopen('/Users/php/acuweb_helpers/out.txt', 'a');
fwrite($handle, $string);
fwrite($handle, $stuff);
fclose($handle);
?>So, the problem is that the exec() fails. I have checked permissions and they are wide open. I even modifed the command to be like this (to try and force the command to be executed as root user):
sudo -u root -S /usr/bin/sips --resampleWidth 60 $path --out $thumb_path < /etc/root.secret