通过PHP帮助执行命令

问题描述:

我试图运行一个PHP exec命令。它在我的CMD中像一个魅力一样运行,但当我通过PHP尝试时它不会执行任何操作。有人能看到我在这里做错了吗?通过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

相关,[你怎么跑.bat file from PHP?](http://*.com/q/835941) – jww 2016-11-15 04:02:00

exec呼叫中的内容与命令中的内容不同。你摆脱了关于命令和它的论点的一系列引语。他们可能很重要。

missing quotes

+0

是的,这是看看会执行什么,但它不显示任何内容。 – Chirag 2011-02-03 08:11:53

在Windows中,EXEC()发出内部呼叫 “CMD/C your_command”。这意味着您的命令必须遵循cmd.exe规定的规则,其中包含一整套围绕完整命令的引用。希望这些链接会有所帮助

http://php.net/manual/en/function.exec.php

http://ss64.com/nt/cmd.html

当你执行两个或铁道部命令,你必须单独他们
试试这个

 
echo exec("C:\\Program Files (x86)\\PHP\\v5.3\\php-cgi.exe", "C:\\inetpub\\wwwroot\\dev_site\\images\\$destination\\thumbs.php");