View Single Post
Old 01-15-2014, 07:35 PM   #1
mzmm
Groupie
mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.mzmm has not lost his or her sense of wonder.
 
mzmm's Avatar
 
Posts: 171
Karma: 86271
Join Date: Feb 2012
Device: iPad, Kindle Touch, Sony PRS-T1
kindlegen via php on linux server

hi all,

i'm trying to set up a server-side EPUB>MOBI converter on a linux server using kindlegen via php. i've uploaded the linux kindlegen, but am unable to invoke it.

i'm using the following:

Code:
<?php

session_start();
ob_end_flush();
ob_start();
set_time_limit( 0 );
error_reporting( 0 );

$ebook  = "book.epub";
$cwd    = getcwd() . "/";
$cmd    = $cwd . "kindlegen_linux_2.6_i386_v2_9/kindlegen " . $ebook;

$descriptorspec = array(
   0 => array( "pipe", "r" ),   // stdin is a pipe that the child will read from
   1 => array( "pipe", "w" ),   // stdout is a pipe that the child will write to
   2 => array( "pipe", "w" )    // stderr is a pipe that the child will write to
 );
ob_flush();
$process = proc_open( $cmd, $descriptorspec, $pipes );
echo "<p>";
if ( is_resource( $process ) ) {
    while ( $s = fgets( $pipes[1] ) ) {
        echo str_repeat( ' ',1024*64 );  // whitespace
        print $s . "<br />";

        if ( $e = fgets( $pipes[2] ) ) {
            echo str_repeat( ' ',1024*64 );
            print $e . "<br />";
            ob_flush();
        }

        ob_flush();
    }
} else{
    echo "error";
}
echo "</p>";
proc_close( $process );
because i'd like to be able to report back to the user realtime, but even

Code:
<?php

$ebook  = "book.epub";
$cwd    = getcwd() . "/";
$cmd    = $cwd . "kindlegen_linux_2.6_i386_v2_9/kindlegen " . $ebook;

exec( $cmd );
is reloading a white screen without generating the mobi file. the paths are correct, so i'm not sure what the issue would be, or even how to troubleshoot it.

googling isn't turning much up, so if anyone had any suggestions i'd be greatful!

Last edited by mzmm; 01-15-2014 at 08:18 PM.
mzmm is offline   Reply With Quote