我正在尝试运行PHP exec命令。它在我的CMD中像魅力一样运行,但是当我通过PHP尝试时它没有做任何事情。有人能看到我在这里做错了吗。
感谢。
<?php
//Command line command
//"C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" "C:\inetpub\wwwroot\dev_site\images\0000\thumbs.php"
//This runs perfectly fine.
echo "Command line execution started<br />";
//This is when $desination is already set to 0000
echo exec("C:\\Program Files (x86)\\PHP\\v5.3\\php-cgi.exe C:\\inetpub\\wwwroot\\dev_site\\images\\$destination\\thumbs.php");
echo "<br />Command line command successful";
//Does not run
?>
答案 0 :(得分:6)
exec
来电中的内容与您的评论中的内容不同。你摆脱了命令及其参数周围的引号集。它们可能很重要。
答案 1 :(得分:1)
在Windows中,exec()发出对“cmd / c your_command”的内部调用。这意味着您的命令必须遵循cmd.exe强加的规则,其中包括完整命令周围的一组额外引号。希望这些链接有用
答案 2 :(得分:1)
执行两个或多个命令时,必须将它们分开 试试这个:
echo exec("C:\\Program Files (x86)\\PHP\\v5.3\\php-cgi.exe", "C:\\inetpub\\wwwroot\\dev_site\\images\\$destination\\thumbs.php");