If you are using PHP to execute a custom-written shell script, keep in mind that the $PATH for the web server’s user can be different than the user account you’re using to execute it. Meaning, if it doesn’t behave properly, try using full paths to programs. For example, when writing a shell script to generate thumbnails for JPGs in a directory:
cd $1
for i in `ls | egrep -i '\.jpg$'`; do
/usr/local/bin/convert $i -thumbnail $2x$3 thumb_$i
done
Just using “convert” rather than “/usr/local/bin/convert” doesn’t work, since /usr/local/bin is not part of $PATH for the web server.