奇怪的是,在我的本地主机上一切都很好,但在我的服务器上却没有.
如上所述,通过ssh登录的exiftool命令运行正常.
但是在php测试脚本中运行(注意我已经在每个测试目录上安装了exiftool,并且它通过ssh运行),没有任何东西可以访问,尽管它以用户orangeman运行…
它失败了
这是一个更新 – 整天都在这里:
在shell上:
-bash-4.1$which exiftool -a ~/perl5/bin/exiftool /usr/bin/exiftool ~/perl5/bin/exiftool
在PHP shell_exec(‘exiftool -a’);
/usr/bin/exiftool
以下是该文件链接到的内容:
lrwxrwxrwx 1 root root 33 May 15 02:10 exiftool -> /home/orangeman/perl5/bin/exiftool
我也尝试创建各种符号链接,通过putenv()篡改主$PATH变量;在PHP …我真的在这里黑暗.适用于localhost,而不是专用服务器.
我用赏金更新了这个 – 这是一个严重的问题.
我在专用服务器上,问题如上所述.
UPDATE
根据@gcb的建议,我能够打印出php的exec()函数运行系统命令时发生的错误.
PHP
<?php exec('exiftool 2>&1',$output,$r); var_dump($output,$r); ?>
输出:
array(2) { [0]=> string(230) "Can't locate Image/ExifTool.pm in @INC (@INC contains: /bin/lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /bin/exiftool line 33." [1]=> string(59) "BEGIN failed--compilation aborted at /bin/exiftool line 33." }
UPDATE
@ gcb的解决方案奏效了.非常感谢你.
解决方法
这里回答http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=2217.0
You either have to install the ExifTool libraries in the standard location (ie. somewhere in the @INC directories listed in your post),or add the location to the include path,something like this: Code: #!/usr/bin/perl BEGIN { unshift @INC,"PATH_TO_DIRECTORY_CONTAINING_LIBRARIES" } use Image::ExifTool; You should be able to add "Image/ExifTool.pm" to the path you add to find the ExifTool module. - Phil
我仍然认为使用上一个答案的#3建议会解决它.如果没有,你真的想知道原因,创建一个新的perl脚本,只输出@INC的内容并通过shell和php运行它.你会看到差异,然后你需要找到哪些登录脚本没有在php中被尊重并打开一个针对php的bug for shell_exec不尊重它…
虽然对您的问题更简单的解决方案(因为它看起来您对解释不太感兴趣)是在调用脚本之前设置PERLLIB var.
那么,就这样做:
> find / -name ExifTool.pm这将告诉你lib的安装位置.让我们说这会返回/example/perl/Image/ExifTool.pm>将PERL5LIB = / example / perl /附加到您的exec()调用.> exec(“PERL5LIB = / example / perl / sudo /var/www/myscript/execscript.sh {$param}”);