从PHP执行外部程序(kindlegen)没有完成没有任何错误

时间:2017-05-31 09:45:38

标签: php kindlegen

我正在使用PHP和kindlegen程序创建mobi文件生成器。

我有: - 路径/var/www/webook_disk/中的kindlegen文件 - PHP脚本

echo exec(./kindlegen /var/www/webook_disk/books_drafts/1234/book.opf -o 1234.mobi)
  • 预订/var/www/webook_disk/books_drafts/1234/
  • 中的文件

当我运行PHP脚本时,我得到了这个日志:

Info(prcgen):I1002: Parsing files  0000002

当我从控制台运行./kindlegen /var/www/webook_disk/books_drafts/1234/book.opf -o 1234.mobi时,我得到了这个日志:

*************************************************************
 Amazon kindlegen(Linux) V2.9 build 1028-0897292 
 A command line e-book compiler 
 Copyright Amazon.com and its Affiliates 2014 
*************************************************************

Info(prcgen):I1047: Added metadata dc:Title        "Przykładowa książka"
Info(prcgen):I1047: Added metadata dc:Creator      "webook"
Info(prcgen):I1047: Added metadata dc:Publisher    "webook"
Info(prcgen):I1002: Parsing files  0000002
Info(prcgen):I1016: Building enhanced PRC file
Info(prcgen):I1015: Building PRC file
Info(prcgen):I1006: Resolving hyperlinks
Warning(prcgen):W14001: Hyperlink not resolved:  /2010/07/Wyprawa-zlodzieja-do-Mazeri.html
Warning(prcgen):W14002: Some hyperlinks could not be resolved.
Info(prcgen):I1008: Resolving start reading location
Warning(prcgen):W14016: Cover not specified
Info(pagemap):I8000: No Page map found in the book
Info(prcgen):I1045: Computing UNICODE ranges used in the book
Info(prcgen):I1046: Found UNICODE range: Basic Latin [20..7E]
Info(prcgen):I1046: Found UNICODE range: Latin Extended-A [100..17F]
Info(prcgen):I1046: Found UNICODE range: Latin-1 Supplement [A0..FF]
Info(prcgen):I1046: Found UNICODE range: General Punctuation - Windows 1252 [2013..2014]
Info(prcgen):I1017: Building PRC file, record count:   0000025
Info(prcgen):I1039: Final stats - text compressed to (in % of original size):  61.30%
Info(prcgen):I1040: The document identifier is: "PrzykKadowa_ksiBQka"
Info(prcgen):I1041: The file format version is V5
Info(prcgen):I1031: Saving PRC file
Info(prcgen):I1033: PRC built with WARNINGS!
Info(prcgen):I1007: Resolving mediaidlinks
Info(prcgen):I1011: Writing mediaidlinks
Info(prcgen):I1009: Resolving guide items
Info(prcgen):I1017: Building PRC file, record count:   0000027
Info(prcgen):I1039: Final stats - text compressed to (in % of original size):  60.45%
Info(prcgen):I1041: The file format version is V8
Info(prcgen):I1032: PRC built successfully
Info(prcgen):I15000:  Approximate Standard Mobi Deliverable file size :   0002209KB
Info(prcgen):I15001:  Approximate KF8 Deliverable file size :   0002215KB
Info(prcgen):I1037: Mobi file built with WARNINGS!

看起来PHP脚本没有完成执行kindlegen程序并在Info(prcgen):I1002: Parsing files 0000002

上停止

可能是什么原因?

**更新1 ** 当我将php命令从exec更改为shell_exec时,输出就是这样的: 我将命令更改为shell_exec,这里是日志:

*************************************************************
 Amazon kindlegen(Linux) V2.9 build 1028-0897292 
 A command line e-book compiler 
 Copyright Amazon.com and its Affiliates 2014 
*************************************************************

Info(prcgen):I1047: Added metadata dc:Title        "Przykładowa książka"
Info(prcgen):I1047: Added metadata dc:Creator      "webook"
Info(prcgen):I1047: Added metadata dc:Publisher    "webook"
Info(prcgen):I1002: Parsing files  0000002

所以我使用哪个命令并不重要。问题是它突然停止了。

今天我发现var/crash报告了错误: 但是日志很长,所以我把它放在了主旨中: https://gist.github.com/blaszczakphoto/a32fd65384fcd8dd4f48751bfd78e699

1 个答案:

答案 0 :(得分:0)

Looking at the documentationexec的返回值如下:

  

命令结果的最后一行。如果你需要执行一个   命令并将命令中的所有数据直接传回   没有任何干扰,请使用passthru()函数。

您可能需要使用shell_execpassthru