问题是关于从PHP运行外部命令。请在下面找到我的代码。
$htmlcontent=$_POST['source'];
echo $htmlcontent;
if(!isset($htmlcontent)){die('No HTML Cannot Proceed');}
$sourcefile='sourcefile.html';
$htmlfile=fopen($sourcefile,'w') or die('Open Failed');
fwrite($htmlfile,$htmlcontent);
fclose($htmlfile);
if(!file_exists($sourcefile)){die('File Creation failed');}
$command="CutyCapt --html=sourcefile.html --out=trials.png";
echo 'Executing'.shell_exec($command);
我正在尝试使用CutyCapt生成所提供的源HTML的快照。我的CutyCapt从命令行运行良好,它还生成快照。但当我像在代码中写的那样运行它时,什么都没有发生。
我试着从它执行ls
之类的普通命令。这些命令也在Web服务器上运行。对此感到困惑,有人能给我一些建议吗?
我哪里可能出了问题?我在垃圾箱里有CutyCapt,准备在终端执行。
我使用的是Ubuntu 11.10和PHP 5.3。
知道吗?感谢
使用system()或exec()和passthrough在php.net 上查找