lackingpregmatch
lackingpregmatch

Reputation:

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.

Upvotes: 1

Views: 2621

Answers (2)

lackingpregmatch
lackingpregmatch

Reputation:

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);

Upvotes: 0

Bill
Bill

Reputation: 2633

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.

Upvotes: 1

Related Questions