0

Hello Guys I am average in server configuration.I am using php exec function to run some commands in my website.But it stopped working if i enable PHP-FPM. Anybody knows why it cause this issue ? Below is php function to run the command

$cmd="pdftk " . $pdf_to_fill . " fill_form " . $fdf_file . " output $outputfile 2>&1";
exec($cmd, $output, $return_var);

Thanks in advance for your help.

Manoj Dhiman
  • 5,096
  • 6
  • 29
  • 68

1 Answers1

-1

This can be a few things, first, try to confirm if exec is enabled, if safe mode is enabled, and if we're in a jailed shell.

The first two can be done with this script, just see what it outputs when you access it:

if(function_exists('exec')) {
    echo '<h1>exec is available.</h1>';
}
if( ini_get('safe_mode') ){
    echo '<h1>Safe mode is on.</h1>';
}

The jailed shell is a little harder to detect, but running var_dump(scandir('/bin/')) will give an indication, if it has a lot less files in it than if your run ls -ltr /bin from the command line, then you're in a jailed shell.

Also, it may be worth using the full path of the pdftk binary, and if it still doesn't work, try running is_executable on the path for pdftk.

ThomasRedstone
  • 379
  • 1
  • 4
  • 13