Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a limit on the length of command passed to exec in PHP?

Tags:

php

pdftk

Currently I need to merge that 50+ PDF files into 1 PDF. I am using PDFTK. Using the guide from: http://www.johnboy.com/blog/merge-multiple-pdf-files-with-php

But it is not working. I have verified the following:

  1. I have tried the command to merge 2 pdfs from my PHP and it is working.
  2. I have echo the final command and copied that command and paste into command prompt and run manually and all the 50 PDFs are successfully merged.

Thus exec in my PHP and the command to merge 50 PDFs are both correct but it is not working when done together in PHP. I have also stated set_time_limit(0) to prevent any timeout but still not working.

Any idea what's wrong?

like image 738
aandroidtest Avatar asked Nov 22 '25 19:11

aandroidtest


1 Answers

You can try to find out yourself:

print exec(str_repeat(' ', 5000) . 'whoami');

I think it's 8192, at least on my system, because it fails with strings larger than 10K, but it still works with strings shorter than 7K

like image 95
nice ass Avatar answered Nov 24 '25 07:11

nice ass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!