05-03-2010, 05:29 AM | #1 |
Member
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? |
05-03-2010, 07:11 AM | #2 |
Wizard
Posts: 4,553
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?
|
Advert | |
|
05-03-2010, 07:33 AM | #3 |
Member
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. |
05-03-2010, 10:21 AM | #4 |
creator of calibre
Posts: 44,329
Karma: 23661992
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
|
05-24-2010, 03:03 AM | #5 |
Member
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?
|
Advert | |
|
05-24-2010, 03:40 AM | #6 |
Member
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 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 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'; } |
05-24-2010, 03:58 AM | #7 |
Member
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. |
05-24-2010, 05:24 AM | #8 |
Wizard
Posts: 4,553
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.
|
|
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 | 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 |