...

View Full Version : exec() problem



daemonkin
07-24-2007, 03:49 PM
Hi,
Using exec to run an ImageMagick script after using move_uploaded_file to a temp folder in my directory:



exec(convert /home/twsports/public_html/images/news/tmp/main_football.jpg -resize 150x150 /home/twsports/public_html/images/news/main_football.jpg)


I have chmod the /news/ and /news/tmp/ directories to 777 to allow read/write/execute

The file is being moved to tmp but the exec function is not working.
When I ssh the command it works.

Any ideas?

firepages
07-25-2007, 01:22 AM
try the full path to convert ('which convert' on the command line)
e.g.


<?
exec('/usr/bin/convert /home/twsports/public_html/images/news/tmp/main_football.jpg -resize 150x150 /home/twsports/public_html/images/news/main_football.jpg');
?>

daemonkin
07-25-2007, 10:20 AM
Firepages: Tried that to no effect.

Anyone else got a suggestion? I would gladly try anything at this stage. It has been working previously but I must have configured something on the server to conflict with the command.

D.

ess
07-25-2007, 10:55 AM
Try and check the following

1- Your server has access to the directory where you are running the exec command. Sometimes Apache is restricted to a specific folder and therefore, it won't execute if Apache doesn't have access to that folder.

2- Check that your server support the exec function. Some hosts might disable this function altogether for security reasons.

3- Please check what output is generated when you run the exec command
exec( "comamnd", $output );
print_r( $output);

If your server is running on a windows machine, you might have to alter the privileges under which Apache runs on, in order to grant it access privileges to System commands.

Otherwise, check the following url which provides an alternative approach to the exec command

http://drupal.org/node/14002

Cheers,
Ess

daemonkin
07-25-2007, 02:37 PM
Problem has been sorted with some server admin help and a reboot.

I have been using the convert lib of Imagemagick without problem since it was installed on my server. Recently it just stopped working from the script although the ssh manual command worked fine.

I am keeping an eye on it and using the full path name of the lib file just in case

D.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum