0

I am trying to get the exec() function to file off a commad for pdftk and it is neither working and I cannot figure out how to capture the error if one is being thrown.

I tried:

$output = array();
$return_var = -1;
exec('pdftk RabiesVacCert.pdf fill_form vac.fdf output vaccine_cert.pdf flatten',$output,$return_var);
if ($return_var === 0) {
    //Record the success
}else{
    throw new \Exception(implode("\n", $output));
}

and:

$output = array();
$return_var = -1;
exec("pdftk /full/path/to/folder/where/class/is/RabiesVacCert.pdf fill_form /full/path/to/folder/where/class/is/vac.fdf output /full/path/to/folder/where/class/is/Shotsvaccine_cert.pdf flatten",$output,$return_var);

if ($return_var === 0) {
    //Record success
}else{
    throw new \Exception(implode("\n", $output));
}

and nothing is happening. Any ideas what I am doing wrong with exec() or how I can show the errors? Running on Ubuntu 14.04 and it works fine via command line on server.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Wally Kolcz
  • 1,604
  • 3
  • 24
  • 45

2 Answers2

0

I changed it to shell_exec() and it works fine now.

Wally Kolcz
  • 1,604
  • 3
  • 24
  • 45
0
shell_exec

Execute command via shell and return the complete output as a string.

see the Documentation.

Bilal
  • 2,883
  • 5
  • 37
  • 60