4

Using CentOS 6.3x64.

I'm trying to run wkhtmltopdf (from here) from a PHP script. I can successfully call wkhtmltopdf-amd64 directly via SSH. But when calling it from PHP via exec, it always fails with exit code 127. The path is correct, so that isn't the issue. I can successfully use exec to call ls and id etc, so the problem seems to be specific to calling wkhtmltopdf-amd64.

I would presume this somehow relates to permissions, but I'm not sure what steps to take. I've tried apache:apache and other ownerships on the program and it has 755 permissions.

Thanks for any guidance!

Additional note:

Sorry for not clarifying further above -- I have confirmed the issue does not relate to the path to the program. I'm using the full absolute path. I've confirmed that the exact same command can be run from the SSH line without problem (regardless of the pwd). I've also created a shell script:

#!/bin/sh
echo 'hello, world!'

I can call this script via exec and it works properly. However, if I modify it to be

#!/bin/sh
echo 'hello, world!'
/full/path/to/wkhtmltopdf-amd64 'http://www.google.com/' /full/path/to/output.pdf

it then fails and returns the exit code 127.

N Rohler
  • 141
  • 1
  • 5

2 Answers2

2

Your shell seems to be unable to find the binary. Try calling it with its full path name (e.g. /usr/bin/ls instead of ls). For further information, see man bash

fuero
  • 9,413
  • 1
  • 35
  • 40
  • thanks for the advice; unfortunately, the path isn't the issue (see additional clarification added to the question). – N Rohler Feb 23 '13 at 16:16
0

I had the same issue a while back. In my case I got 126 without the execution bit set and 127 with the bit set.

I later figured out it was related to some shared libraries missing on the system. Even if the binary is linked statically it seems to use some shared libraries from the system.

I don't really remember which libraries were causing the problem, but this gist: https://gist.github.com/nghuuphuoc/8282411 is a good starting point I think.

Hikaru-Shindo
  • 245
  • 1
  • 2
  • 10