php execute shell commands, dyld: Library not loaded: /usr/lib/libxml2.2.dylib
I am trying to use wkhtmltopdf executable to convert some html to pdf. I'm just testing it out on my mac and if I run the executable via terminal it works fine. If I run it using php shell_exec I get the following error:
dyld: Library not loaded: /usr/lib/libxml2.2.dylib Referenced from: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices Reason: Incompatible library version: DictionaryServices requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0
If I spit out the cmd that I'm using via php I can run it and it works fine in the terminal.
I think it's a pathing issue, so I echoed out my users path which was different than the paths avialble to php, so I added it to the command before:
PATH=$PATH:/usr/lo开发者_高级运维cal/sbin:/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/subversion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin; ./wkhtmltopdf-0.9.9-OS-X.i368 ./'newxhtml.html' /tmp_pdf.pdf
Any thoughts on what I might be doing wrong?
Thanks, MS
Figured out what was going on.
First to trouble shoot I ran the command:
env
From both my terminal and my php secript.
I noticed in my php script that it had the following explicitly set:
DYLD_LIBRARY_PATH=/some/path
But in the terminal that value wasn't set at all. So all I did was add:
DYLD_LIBRARY_PATH="";
Here's my final command: DYLD_LIBRARY_PATH="";./wkhtmltopdf-0.9.9-OS-X.i368 ./'newxhtml.html' ./tmp_pdf.pdf 2>&1
And I just run it via shell_exec.
精彩评论