Tidy runs from command line but not from php
flamingvan - December 11, 2007 - 17:25
| Project: | Import HTML |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I'm getting the message: "
I can run tidy -v from command line but not from php. I tested with the following script:
<?php
$tidypath = '/usr/local/bin/tidy';
$command = escapeshellcmd("$tidypath -v");
$result = exec($command, $response);
print_r($response); //comes up as an empty array
?>I made a simple shell script and placed it in the same directory as tidy and gave it the same permissions and it ran fine from php. selinux is off and so is safe_mode.

#1
So you've got a problem.
You've not got open_base_dir set? I think it warns about that.
It would need some debugging. Can you run other shell stuff, like
<?phppassthru("ls -la ");
?>
?
#2
open_basedir is not set. I can run passthru("ls -la "); and it prints the output.
#3
I just tried running tidy from a php script with a filename instead of the -v argument and it worked, so maybe I'll just disable the tidy test in the module. Still, though, what do you think the problem is?
Here's what I ran:
<?php$tidypath= '/usr/local/bin/tidy';
$command = escapeshellcmd("$tidypath /var/www/html/tidy4aug00/Overview.html");
$result = exec($command, $response);
echo $command;
print_r($response);
?>
It printed a bunch of output. For example:
<?php/usr/local/bin/tidy /var/www/html/tidy4aug00/Overview.htmlArray ( [0] => "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [2] => [3] => [4] => [5] => [6] => "HTML, validation, error correction, pretty-printing" /> [8] => [9] => [44] => [45] => [56] => [57] => [60] => [61] => "navy" vlink="black" alink="red"> [63] => ...
?>
#4
could be that your binary is outputting the -v informatin to STDERR instead or STDOUT or something mysterious.
What did -v tell you when you ran it? what is the version and platform?
#5
"HTML Tidy release date: 4th August 2000
See http://www.w3.org/People/Raggett for details"
Platform is Fedora (5, i think)
#6
I tried installing the module on another server where I have tidy and xslt support working and when I try the demo I get the follow php error:
Fatal error: Call to undefined function warn() in /home/hr/public_html/sites/all/modules/import_html/coders_php_library/file-routines.inc on line 231
Any idea what that's about?
#7
2000 is way old. It's not been very active at all, but I've mainly been using 2005 versions. I've a 2004 on a windows machine.
So it sounds like it's sort of available, but if it were me I'd try to go the private bin method instead, running your own copy local to the module. It's a small binary, so probably no big dependancies.
warn() is a function that should be in debug.inc I think ... or at least it was in one lifetime when I made that old file library. Looks like it was never part of this code stream at all.
The call is indeed a warning about bad things.
<?phpwarn("When trying to copy $from, which looks like it should be $from_local - failed to find it. Could be virtual paths or magic happening, but I can't handle it. Probably just missing.");
?>
- but it's a situation that's never come up in living memory.
I'd recommend you change that line to drupal_set_message() or trigger_error() (same argument string) if you want to see what happened.
I'll patch that library to remove the bad call soon.
Were you trying the demo on a remote URL (needs allow_url_fopen in php.ini)? Or was the path just wrong?