0

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

我有: - 路径中的 kindlegen 文件/var/www/webook_disk/ - 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 命令从更改execshell_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:但是日志很长,所以我把它放在gist中: https ://gist.github.com/blaszczakphoto/a32fd65384fcd8dd4f48751bfd78e699

4

1 回答 1

0

查看文档,的返回值exec如下:

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

您可能想要使用shell_execpassthru

于 2017-05-31T09:53:28.887 回答