-
Sep 6th, 2010, 10:24 AM
#1
Thread Starter
Super Moderator
[RESOLVED] PHP Exec Not running, but command works ok!
I have the following script to take an uploaded PDF in PHP and call ImageMagik/Ghostscript to convert to images of specified size.
Code:
$tmp = exec("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"", $results);
However, this doesnt seem to work. No errors in the log file and no errors on screen. If I do the following,
Code:
$tmp = exec("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"", $results);
echo ("convert \"{$strPDF}\" -resize 500X500 \"{$strOut}\"");
And I paste the output into a command prompt it works fine (It takes around 6-10 seconds - My max_execution_time is at 600.
Any suggestions on why this might not be working?
This is Windows, IIS 7 and PHP5.
Edit: I'm having the same issue in both CentOS and Windows. Both have ImageMagik and Ghostscript installed.
-
Sep 6th, 2010, 12:10 PM
#2
Re: PHP Exec Not running, but command works ok!
can you make sure that the user running IIS (or Apache on CentOS) has the authority to execute those commands?
-
Sep 6th, 2010, 12:38 PM
#3
Thread Starter
Super Moderator
Re: PHP Exec Not running, but command works ok!
Originally Posted by kows
can you make sure that the user running IIS (or Apache on CentOS) has the authority to execute those commands?
Ok I'm not amazing with linux stuff, can you run through how I would go about doing that in CentOs?
-
Sep 6th, 2010, 07:28 PM
#4
Re: PHP Exec Not running, but command works ok!
Use the stat command on the input file and/or the directory where the output file will be written.
Look at the owner setting and the permissions set.
You can use exec('whoami') to find out what user your script is running as.
Also, try trapping the return code from the exec command. Pass a variable into the third parameter and then read that after exec returns.
-
Sep 7th, 2010, 02:01 PM
#5
Thread Starter
Super Moderator
Re: PHP Exec Not running, but command works ok!
Still cant resolve this, the third param comes back as "1". Is there anything else I can do to Debug this?
-
Sep 7th, 2010, 10:47 PM
#6
Re: PHP Exec Not running, but command works ok!
this comment seems helpful for running exec() on Windows, but I'm not sure of the problem for your CentOS install.
the last time I had issues using exec(), I was trying to auto-extract RAR archives using WinRAR. I ended up fixing it, but I'll see if I can't reproduce the problem and give you a solution for at least the Windows side of things. I do have a server running CentOS, so I could look for and see if I run into the problem with ImageMagik or WinRAR on that machine, and let you know what I run into. I can't promise this will be tonight, though!
-
Sep 12th, 2010, 06:13 PM
#7
Re: PHP Exec Not running, but command works ok!
Hi.
I took my time getting back to you! Anyway, I didn't realize ImageMagick was installed on most Unix systems already, so I ran the following to test via the console:
Code:
convert logo.png -resize 120x60 small.png
and it worked fine. Then, I ran the following using PHP 5.3.3 on Apache 2.2.16:
PHP Code:
<?php
exec("convert logo.png -resize 60x30 small.png");
?>
My guess would still be user permissions, I suppose. I'm using a web hosting account with WebFaction, where I don't have a caged shell (whereas most web hosts do limit what you can do via SSH). I also ran the script above using WebFaction's shared install of Apache/PHP5.2 after I had success with my custom install of Apache/PHP5.3, and the results were the same. The directory that the script was running from was chmodded to 755.
-
Sep 13th, 2010, 04:25 AM
#8
Thread Starter
Super Moderator
Re: PHP Exec Not running, but command works ok!
Yea it was a permissions issue, but not somthing that I can work out how I fixed. I have it working well on the CentOS box but windows is still failing. Not a big issue though as CentOS was the main one.
Thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|