开发者

php exec() error values

I have two subsequent exec commands. The first executes without issue the second however is throwing an error:

exec('/usr/bin/pdftk A='. trim($original) .' cat A1 output '. trim($onepage), $output, $error);
var_dump($output); var_dump($error);

exec('/usr/bin/pdftk '. trim($onepage) .' background watermark.pdf output '. trim($modified), $output, $error);
var_dump($output); var_dump($error); 

The first produces:

array(0) { } int(0) 

The second:

array(0) { } int(1) 

The permissions on the php script and directories are exactly the same. I've tried ecaping the exec command using escapeshellargs with no luck either.开发者_开发百科


I'm not sure what your error is, but I would recommend that you reduce some of the background noise so that you can see the problem easier. What I mean by this is the following...

Take

exec('/usr/bin/pdftk A='. trim($original) .' cat A1 output '. trim($onepage), $output, $error);
var_dump($output); var_dump($error);

exec('/usr/bin/pdftk '. trim($onepage) .' background watermark.pdf output '. trim($modified), $output, $error);
var_dump($output); var_dump($error); 

And do

$command1 = '/usr/bin/pdftk A='. trim($original) .' cat A1 output '. trim($onepage);
$command2 = '/usr/bin/pdftk '. trim($onepage) .' background watermark.pdf output '. trim($modified);

exec($command1, $output, $error);
var_dump($output); var_dump($error);
echo $command1;

exec($command2, $output, $error);
var_dump($output); var_dump($error); 
echo $command2;

That way you can cut and paste the output of the command issued onto the unix command line, and perhaps get a better view of what is going on at the unix level.


What ended up working was the following:

   $descriptorspec = array(
      0 => array("pipe", "r"), 
      1 => array("pipe", "w"));
   proc_open('/usr/bin/pdftk '. trim($onepage) .' background watermark.pdf output '. trim($modified), $descriptorspec, $pipes);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜