脚本宝典收集整理的这篇文章主要介绍了php – exec()和phantomjs问题与绝对路径,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
情景
exec('./phantomjs --version',$o,$e); PRint_r($o); echo $e;
1.9.1 // version number 0 // exIT code
这证明我可以通过exec()运行命令,并且phantomJS工作正常.
问题
exec('./phantomjs http://mywebsite.COM/test.js',$e); print_r($o); echo $e;
输出是:
Array ( ) // empty output 139 // exit code which on investigating turned out to be segmentation fault
我也尝试过:
exec('./phantomjs ./test.js',$e); // since phantomjs and test.js are in same folder
但结果是一样的(段错误)
test.js代码:
VAR page = require('webpage').create(); var url = 'http://www.rediff.com/'; page.oPEn(url,function (status) { phantom.exit(); });
//throws a lot of errors because seArching some libraries $cmd = 'unset DYLD_LIBRARY_PATH ;'; $cmd.= ' /abs/path/to/phantomjs'; $cmd.= ' /abs/path/to/script.js'; //set environment variable to node source putenv('PATH=/abs/path/to/node/bin/'); //Now exec the cmd and pipe the errors to stdout exec($cmd.' 2>&1',$output); //and output the results print_r($output);
以上是脚本宝典为你收集整理的php – exec()和phantomjs问题与绝对路径全部内容,希望文章能够帮你解决php – exec()和phantomjs问题与绝对路径所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。