Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 05-03-2010, 05:29 AM   #1
conryf
Member
conryf began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: none
Running ebook-convert from php

Hello,

I'm trying to run ebook-convert from php using the exec command. I think it's a permission problem. I made www-data the owner of /usr/bin/ebook-convert and it is the user of all the relevant files, all with permission 755. Any idea why I can't run this from php?
conryf is offline   Reply With Quote
Old 05-03-2010, 07:11 AM   #2
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
Do you have things like the search path set up correctly when run from php so that Calibre can find all its constituent parts?
itimpi is offline   Reply With Quote
Advert
Old 05-03-2010, 07:33 AM   #3
conryf
Member
conryf began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: none
well the php code is:

exec("ebook-convert book.txt book.epub");

I ran it from the command line and it say there is a permissions error writing to the directory. The directory has permissions 755 and is owned by www-data, which is the user php runs as.

If I change the permission to 777, I can get it to work, but only from command line, if I run the page in a browser I get the same permissions error even when the relevant files are 777!

How could you get a permissions errro when the directory is 777!? I'm baffled.
conryf is offline   Reply With Quote
Old 05-03-2010, 10:21 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,852
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
check the permissions on you're temp directory and the calibre config directory (~/.config/calibre) Use the environment variable CALIBRE_CONFIG_DIRECTORY to control that
kovidgoyal is offline   Reply With Quote
Old 05-24-2010, 03:03 AM   #5
conryf
Member
conryf began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: none
Still trying

I changed all the permission in ~/.config/calibre but where do I find what calibre is using as the temp directory?
conryf is offline   Reply With Quote
Advert
Old 05-24-2010, 03:40 AM   #6
conryf
Member
conryf began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: none
More info

I can run the ebook-convert command from comand line and even run

Code:
php convert_test.php
with the following results:

Code:
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/imap.ini on line 1 in Unknown on line 0
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
ebook-convert content/Fiction/Multi-Cultural/Celtic_Fairy_Tales.txt Celtic_Fairy_Tales.epub1% Converting input to HTML...
InputFormatPlugin: TXT Input running
on /var/www/content/Fiction/Multi-Cultural/Celtic_Fairy_Tales.txt
InputFormatPlugin: HTML Input running
on /var/www/content/Fiction/Multi-Cultural/temp_calibre_txt_input_to_html.html
Language not specified
Creator not specified
Title not specified
Building file list...
Forcing temp_calibre_txt_input_to_html.html into XHTML namespace
34% Running transforms on ebook...
Merging user specified metadata...
Detecting structure...
Auto generated TOC with 0 entries.
Flattening CSS and remapping font sizes...
Source base font size is 12.00000pt
Cleaning up manifest...
Trimming unused files from manifest...
Creating EPUB Output...
67% Creating EPUB Output
	Looking for large trees in temp_calibre_txt_input_to_html.html...
	No large trees found
Generating default cover
EPUB output written to /var/www/Celtic_Fairy_Tales.epub
Output saved to   /var/www/Celtic_Fairy_Tales.epub
<br>ret_val=0<br><br>OK
where convert_test is the following

Code:
$command = 'ebook-convert content/Fiction/Multi-Cultural/Celtic_Fairy_Tales.txt Celtic_Fairy_Tales.epub';

echo $command;
if( system($command , $ret_val) )
{
echo "<br>ret_val=$ret_val<br>";
echo '<br>OK';
}
else
{
    echo '<br>fail';
}
But I can't do it from a browser, (ie from apache). The return value of system is false. No other output. Any ideas?
conryf is offline   Reply With Quote
Old 05-24-2010, 03:58 AM   #7
conryf
Member
conryf began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Feb 2010
Device: none
OK, I think I've solved this problem on my own.

Calibre was running in /var/www and was trying to create a directory /var/www/.config. However I was the owner of /var/www, not apache. If I ran it from commandline I assume it used the .config in my home directory, but when apache ran it (as www-data on ubuntu) is was trying (and failing) to create /var/www/.config.

When I changed the owner of /var/www/ to www-data it worked fine.

Thanks everyone for all their help.
conryf is offline   Reply With Quote
Old 05-24-2010, 05:24 AM   #8
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
That suggests that you could also have solved the problem by setting the CALIBRE_CONFIG_DIRECTORY to point to the Calibre config directory in your home folder.
itimpi is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which PHP version do you have? erayd Workshop 2 10-04-2010 08:02 PM
Ebook Sony Running slow janerol Reading and Management 1 02-12-2010 07:42 AM
Using PHP to convert PDFs joedevon PDF 5 07-05-2009 10:50 PM
PHP 5 programming e-book available for free Colin Dunstan Deals and Resources (No Self-Promotion or Affiliate Links) 0 05-13-2005 11:43 AM


All times are GMT -4. The time now is 01:41 AM.


MobileRead.com is a privately owned, operated and funded community.