Quantcast
Channel: MobileRead Forums - Kindle Developer's Corner
Viewing all articles
Browse latest Browse all 4457

kindlegen via php on linux server

$
0
0
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!

Viewing all articles
Browse latest Browse all 4457

Trending Articles