Forum How do I...?

Prince Called, No Output

jimbrooking
Hello again. My problems continue. I am running Prince 10 at a new hosting co. using the PHP interface. I have installed Prince in the /home/usr directory, have changed the references to the new (/home/usr) directory in the PHP code that instantiates Prince and in the Prince shell script that calls Prince. I believe I have all the permissions set to allow Prince execution, write to its various output files, etc. I have added to the prince shell script code that writes to /home/tmp/out.pr.log when the script is run - and it seems to run, according to the log, registering in the log an entering message with time stamp. Also prints a return message with time stamp and return code (always zero). I have tried to turn on verbose on the command line that executes home/usr/lib/prince. I have added $prince->setLog() to write a log file from Prince execution to the same file that my entering/exit files go into.

But there is nothing in the log file from Prince, and the PHP file is not created. I think I am about out of tricks in diagnosing this and wonder if you have any suggestions.
mikeday
So the Prince shell script is running, but it sounds like the binary is not. Does it run successfully from the command-line? Can you echo the exact command the shell script is running and try running that from the command-line?
jimbrooking
I don't believe I can run a command line on this server. Have written a ticket to see if tech support will run it for me. The ticket I wrote:
I'm still trying to get the subject of my previous ticket to run. I have added some debugging printouts and logging but the key step, which actually performs the operation (reading an XHTML file and several CSS files, and creating a PDF therefrom) does not appear to be executing. The author of the program suggests running the program (/home/fearrin1/usr/lib/prince/bin/prince) from the command line. I don't think I can do this without setting up a TTLS (?) account, and I would need this so seldom it seems not to be worth the effort. I wonder if you could try to execute the statement in question and let me know the result, i.e., what, if anything it prints out. The statement to run is this:

/home/fearrin1/usr/lib/prince/bin/prince --verbose --prefix="/home/fearrin1/usr/lib/prince" "$@"

The software in question comes from the following source: http://www.princexml.com/ and is used to create well-formatted PDF documents from material on my community website, e.g., our 104-page directory of residents.

Thanks for your help.
jimbrooking
Well that was certainly quick! Here's the reply:
Hello Jim,

I executed the command per your request, and here is the output:

Code:
fearrin1@serv01 [~]# /home/fearrin1/usr/lib/prince/bin/prince --verbose --prefix="/home/fearrin1/usr/lib/prince" "$@"
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libidn.so.11: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /usr/lib64/libxml2.so.2: no version information available (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /home/fearrin1/usr/lib/prince/bin/prince)
/home/fearrin1/usr/lib/prince/bin/prince: /lib64/libc.so.6: version `GLIBC_2.11' not found (required by /home/fearrin1/usr/lib/prince/bin/prince)

There's obviously a problem, but what...?
mikeday
Looks like it's the wrong Prince package for this server. What Linux distribution is it running, and is it 32-bit or 64-bit?
jimbrooking
Support says
The Linux distribution is CentOS 6.5

It is 64-bit.
mikeday
In that case it would be best to install the 64-bit Prince package for CentOS 6.

If the RPM cannot be installed in the system folders, there is also a .tar.gz package which can be installed in your home directory.
jimbrooking
OK, quickly, I copied the prince library from prince-10r6-centos6-x86_64 and uploaded it and it's behaving differently. I need to quit for tonight. Maybe back tomorrow to let you know if it worked.
jimbrooking
Another day - Still not doing the conversion to PDF. I have a PHP program that attempts to convert a pre-prepared XHTML file to PDF. I put some debugging printouts into the Prince class in the PHP interface, one of which just echos that the __construct function has run, and the other around the call to the function convert_internal_file_to_file. All three printouts work, so the class is loaded, apparently constructed, and the function convert_file is being called. The printout before the call to convert_internal_file_to_file prints the variable $pathAndArgs:
=====Debugging printout Called by convert_file at line 350=====

pathAndArgs to call convert-internal-file-to-file
=String(208)"/home/fearrin1/usr/prince --server -s "/home/fearrin1/public_html/newprint/printing.css" --log="/home/fearrin1/public_html/newprint/new_directory.log" "/home/fearrin1/public_html/newprint/new_directory.xhtml""

=====End Debugging printout=====

And the other, after the call to convert_internal_file_to_file prints the $msg array returned by the function. This prints:
=====Debugging printout Called by convert_file at line 353=====

msgs from conversion
=NULL(0)NULL

=====End Debugging printout=====

Yet the return from prince->convert_file evaluates as FALSE and no PDF file is created.

When the code is run on the old server, it executes correctly and produces a 104-page PDF of our community directory. Output from running on old server (no added statements for debugging in the Prince object) and the new server are attached, as is the program that generates both.

Thoughts?

Thanks.
  1. - http___www.fearringtonfha.pdf72.4 kB
    Output running on old server
  2. prince.php3.4 kB
    PHP code that runs on current site
  3. www.fearringtonfha.org prince.php.pdf20.9 kB
    Output when running on new server
mikeday
Perhaps PHP does not have write permissions to the public_html directory, only read permissions?

Does that exact command-line work as expected when you run it manually yourself?
jimbrooking
The XHTML file is written by PHP so, yes, PHP can write to /public_html/newprint. Both the XHTML file and the PDF file (copied when the site was moved from old hosting company) has 0644 permissions. The directories /public_html and /public_html/newprint both have permissions 0755.

I have again asked SiteGround tech support to run the same command, and they have done so, with the following result:

fearrin1@serv01 [~/public_html]# /home/fearrin1/usr/lib/prince/bin/prince --verbose --prefix="/home/fearrin1/usr/lib/prince" "$@"
-bash: /home/fearrin1/usr/lib/prince/bin/prince: Permission denied

The file /usr/lib/prince/bin/prince HAD a permission of 0644, when the above was tried, but I changed the file's permissions to 0755 and tried again - same result, no PDF file generated.

The directories /home/usr, /home/user/lib, /usr/lib/prince and all the subdirectories under the last all have permissions 0755, as does the file /usr/lib/prince/bin/prince, now.

Since I was not able to run the install script (lacking privs on the server), I uploaded all the lib files (binary FTP and moved them into place under usr/lib/prince. I expect they carried their privileges with them. A quick look showed everything except the prince binary and all but one in the dtd directory had a 0644 permission. The prince binary and the dtd files all have 0755.
mikeday
So the "Permission denied" error was caused by the prince binary not having execute permissions, but this has since been changed. Can you ask them to run again from command-line? At least it should return a different error message now. :)
jimbrooking
fearrin1@serv01 [~]# /home/fearrin1/usr/lib/prince/bin/prince --verbose --prefix="/home/fearrin1/usr/lib/prince" "$@"
/home/fearrin1/usr/lib/prince/bin/prince: error while loading shared libraries: libgif.so.4: cannot open shared object file: No such file or directory
mikeday
Okay that's definitely progress! A system library is missing, but this can be fixed if the server admins are gracious enough to run "yum install giflib".

If they are not willing to do this, perhaps it will be necessary to install the generic Linux package instead of the CentOS package, which would not be ideal.
jimbrooking
The error message mentions libgif, not giflib. Should the yum command mention libgif instead of giflib?
mikeday
No, they call the package giflib just to be annoying. :)
jimbrooking
Here is their response:
Currently your account is hosted on one of our shared server. Due to the fact that this is a shared environment we are using server configuration which cannot be altered or customized. I am afraid that we cannot install the additional library on the shared server.

If this setup is mandatory for your application I strongly recommend that you consider upgrading to one of our Dedicated solutions where you will be the sole server user, and you will be able to preform all the server customizations, that you desire:

A dedicated server would raise the cot from USD$15/month to USD$229/month (minimum), which isn't feasible.

The first time I contacted you about this problem I had installed the generic Linux package, and that generated many more error message (see 4th post in this thread).

Is there any way for me to obtain a prince-linkable libgif and install it in my user/lib directory?
mikeday
You can download the appropriate RPM file, extract its contents with cpio, copy it into your own directory, and run Prince with LD_LIBRARY_PATH specifying the directory where libgif.so is located. This is a bit tricky, though.
jimbrooking
OK, I think I have libgif in my local directory (see attached). Now, can you help with the definition of LD_LIBRARY_PATH given this structure? I assume the definition would be in the shell script "prince" which currently reads
#! /bin/sh
echo called >> /tmp/prince.log
PROGRAM="prince"
prefix=/home1/fearrin1/usr
exec $prefix/lib/$PROGRAM/bin/$PROGRAM --prefix="$prefix/lib/$PROGRAM" "$@"

Thanks.
  1. screen.1.jpg130.7 kB
    Library Structure on Server with libgif
mikeday
Before the exec call try:
export LD_LIBRARY_PATH="/path/to/usr/lib/giflib"
jimbrooking
Loads Prince without error. Next problem: no fonts available.
PDF Conversion Messages - PDF Generation Failed

Array(2)
(
| ['0']=>Array(3)
| (
| | ['0']=String(3)"wrn"
| | ['1']=String(48)"/home/fearrin1/public_html/newprint/printing.css"
| | ['2']=String(29)"failed to parse all CSS rules"
| )
| ['1']=>Array(3)
| (
| | ['0']=String(3)"err"
| | ['1']=String(0)""
| | ['2']=String(18)"no available fonts"
| )
)
=====End Debugging printout=====
mikeday
Progress! You will need to install some fonts. Since you can't install system packages, this will involve copying the TTF files that you wish to use and putting them in an accessible directory, then creating a CSS style sheet that defines the default "serif" font family as described here.

I would suggest installing the Microsoft Core Fonts, or the DejaVu fonts.
jimbrooking
Mike, I copied over some FreeFonts I found on one of my Virtual (Ubuntu) boxes, did the font-mapping thing, and lo and behold...success!

Your patience with me through this transition has been boundless. Lesser men would have given up long ago. Can't thank you enough for your perseverance in the face of my unix illiteracy!
  1. PDF Directory.pdf27.0 kB
    Yeeee-Haaaa!
mikeday
I'm glad to hear it's working, thank you for your perseverance in sticking with it! :D