Page 1 of 1
PHP exec command issue
Posted: 2010-06-15T08:58:36-07:00
by dave_c00
Hi,
I am having trouble executing the following imagemagick command within my PHP code:
Code: Select all
exec('/usr/local/bin/mogrify -rotate 90 /home/s/test.jpg');
The command:
Code: Select all
/usr/local/bin/mogrify -rotate 90 /home/s/test.jpg
works fine from my command line so am confused as to why it doesn't work when using exec. I have successfully executed a cp command from the script ok so exec is working If I run the PHP script with the exec command in it from the command line using:
it runs fine.
Anyone any ideas..? It is really frustrating as i'm sure it isnt a big problem.
Cheers,
Dave
Re: PHP exec command issue
Posted: 2010-06-15T09:47:55-07:00
by Bonzo
Its probably a path problem and comes up a lot - comand knows where IM is but php does not.
I can not remember the fix; you could search the users and developers sections and see if you can find an answer. The answer may depend if you are on a shared server or one of your own.
What result do these give you:
Code: Select all
<?php
echo "<pre>";
system("type convert");
echo "</pre>";
?>
Alternative method
<?php
echo "<pre>";
system('which convert',$path); print_r($path);
echo "</pre>";
?>
If you are on a windows server you need to change the ' to " I do this anyway.
May be of help:
Set PATH environment variable in the PHP or tell your administartors that the PHP command path is not set right for IM and GS. If the web server has the right path PHP usally inherits it and then it can find things properly!
Re: PHP exec command issue
Posted: 2010-06-16T01:36:22-07:00
by dave_c00
Thanks for your reply,
For some reason when running those 2 commands within PHP I get no response at all for the first one and a 1 for the second.
From the command line on my Linux Server I get the correct paths:
Code: Select all
root@ds6580:~# type convert
convert is /usr/local/bin/convert
Code: Select all
root@ds6580:~# type mogrify
mogrify is /usr/local/bin/mogrify
It seems that the imagemagick commands using the system and exec call are not working.. Getting "type convert" within a PHP script to work will probably get it all to work me thinks..
I am using PHP 5.1.2 and ImageMagick 6.6.2-3.
Any ideas?
Interstingly enough this works:
Code: Select all
echo "<pre>";
system("type cp");
echo "</pre>";
returning:
Cheers
Re: PHP exec command issue
Posted: 2010-06-17T01:49:35-07:00
by dave_c00
Funny I can do a:
Code: Select all
system('type /usr/local/bin/mogrify');
and I get:
Code: Select all
/usr/local/bin/mogrify is /usr/local/bin/mogrify
but not a:
so I am thinking its maybe a user problem or a path problem...