2

I get this error when running a program from www-data.

Error

sudo: no tty present and no askpass program specified

But I have added the following to sudo visudo

www-data ALL = NOPASSWD: /var/bin/poppler-0.65.0/build/utils/pdfimages

The path /var/bin/poppler-0.65.0/build/utils/pdfimages is correct.. I have tested it from a terminal.

Command

sudo /var/bin/poppler-0.65.0/build/utils/pdfimages -list data/scan_voucher/17.pdf

JP. Aulet
  • 4,375
  • 4
  • 26
  • 39
clarkk
  • 27,151
  • 72
  • 200
  • 340

1 Answers1

1

As you said that already setting up sudo visudo correctly, I will first take a look at Tarun Lalwani links, specially the part about disable requiring tty in your sudoers :

Defaults    !requiretty

Try to do the same command but with flag -S actived (sudo -S yourcommand)

The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

If it doesn't work for you, you can try a trick that seems to work like this one (from here):

echo '' | sudo -S your_command

That will send an empty password to first prompt to enter password.

How are you executing this from PHP? Try with:

@exec("sudo /var/bin/poppler-0.65.0/build/utils/pdfimages -list data/scan_voucher/17.pdf");

Hope that it helps!

JP. Aulet
  • 4,375
  • 4
  • 26
  • 39