I'm attempting to run the following command through PHP:
$output = shell_exec('sudo /Users/Derk/Code/automation/psc/pdfs.sh 1'); This runs the following bash script code:
sudo /usr/local/bin/pdftk cvcheck_template.pdf fill_form data.fdf output output.pdf flatten sudo /usr/local/bin/convert -density 150 -gravity south -geometry +0+150 -composite output.pdf signature.png new_output.pdf The bash script works perfectly in the command line but when I attempt to run it via PHP on a web server (MAMP) it does not give me any output. The first command seems to work but the second command gives me nothing.
Any help would be much appreciated.
sudo? First to run the script, and then the script apparently also runssudo. Once is enough... Is the PHP being executed from the shell, or from a webserver? If the latter, check the webserver error log./tmp/debuglogfileand make it writeable by all:chmod 666 /tmp/debuglogfile. Then change the PHP code toshell_exec('sudo /Users/Derk/Code/automation/psc/pdfs.sh 1 2>/tmp/debuglogfile')and see if any error output is written to the logfile. As you write the first command is executed (make sure it is! "seems to work" doesn't cut it), thensudois apparently set up correctly, so permissions shouldn't be the problem... does the user under which the webserver runs have the same sudo rights as you?