【发布时间】:2016-06-14 10:25:28
【问题描述】:
我有一个名为convert3to5 的 C 程序,最初是在 2010 年初为 CentOS/Fedora 32 位系统编写的。我将把它移到新的 CentOS 6.x 64 位系统主机上。
从 CentOS Putty 控制台我可以很好地运行 convert3to5 命令;这是从我的控制台运行的示例:
[root@cloud convert3to5]# ls
CircleStar convert3to5 Convert3To5.txt test.tif
[root@cloud convert3to5]# ./convert3to5 /var/www/webadmin/data/www/mydomain.com/uploads/SV-DIS160217B.tif
TIFFReadDirectory: Warning, /var/www/webadmin/data/www/mydomain.com/uploads/SV-DIS160217B.tif: wrong data type 7 for "RichTIFFIPTC"; tag ignored. Image has an undefined fillorder - using default: MSB2LSB
以上是 convert3to5 的正常完成,我得到了一个 SV-DIS160217B.bmp,它位于 /var/www/webadmin/data/www/mydomain.com/uploads/ 所以从控制台运行它可以正常工作。
问题 - 我正在尝试使用 exec(command, output, return) 命令从 PHP 运行相同的命令,如下所示:
chdir($sv_path.$c3to5_path); //change our working directory to "/convert3to5" directory
$command = "./convert3to5 $targetFile 2>&1";
$result = exec($command, $output, $return);
// the output of the above command - is a .bmp file it will be placed in the same path as the input .tif file
我得到以下 $result:
错误:无法转换 /var/www/webadmin/data/www/mydomain.com/uploads/SV-DIS160217B.tif 到 5 彩色 BMP 文件:打开文件错误:Tiff_3_to_BMP_5_.lut!
我的convert3to5确实需要打开Tiff_3_to_BMP_5_.lut
为什么当我从控制台提示符运行 convert3to5 而不是从 PHP exec(...) 运行时它找到 Tiff_3_to_BMP_5_.lut 在这两种情况下我的密码都显示我在
[root@cloud convert3to5]# pwd
/var/www/webadmin/data/www/mydomain.com/myView/convert3to5
我还从我的 PHP 脚本中验证了 pwd 是正确的
chdir($sv_path.$c3to5_path);
Tiff_3_to_BMP_5_.lut 在 CircleStar 目录中 - CircleStar 的路径是 /var/www/webadmin/data/www/mydomain.com/myView/convert3to5/CircleStar
总结:./convert3to5 有效,而 PHP exec('convert3to5 ..) 似乎无效。
谁能提出不同之处以及如何修复和/或调试? 谢谢
【问题讨论】: