I had a problem while using PHP exec()
. I am not able to figure out the issue and I have tried with following code:
exec("pdfcrop --margins '-6 -2 -3 -2' '/home/username/pdf/Figure 1 Timeline of Virtual Sim Use/page.01.pdf' '/home/username/pdf/out/output.pdf'", $output, $error);
Whenever I use this commands in exec()
it returns status code of 2 but if I use this command to my terminal then it works well. So kindly give your suggestion to solve this problem.
thank you..
php exec function runs the process under the apache user ( www-data ) user most probably this user does not have access to : /home/username/pdf/Figure
You can test this very easy by trying to change this path to /tmp/name of pdf file.pdf
pdfcrop
is a Perl program. Opening it to read, you will find it creates tmp
files in current directory.
It works in PHP call after I made the following changes:
$tmp = "/tmp/tmp-..."
pdftex - add argument -output-directory=/tmp
In case of Linux Debian 9.5 I have got from Php exec()
function return code 2 because wrong console for user www-data in /etc/passwd
file: I had to change line:
www-data:x:33:33:www-data:/usr/sbin/nologin
To:
www-data:x:33:33:www-data:/var/www:/bin/bash
And now error gone and commands are executed as expected!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.