开发者

help with exec command via PHP

I'm trying to run a PHP exec command. It runs like a charm in my CMD but it doesn't do anything when I try it via PHP. Can someone see what I'm doing wrong here.

Thanks.

<?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
?>


What's in your exec call is not the same as what's in your comment as the command. You got rid of the sets of quotes around the command and its argument. They may have been important.

help with exec command via PHP


In Windows, exec() issues an internal call to "cmd /c your_command". This implies that your command must follow the rules imposed by cmd.exe which includes an extra set of quotes around the full command. Hope these links will be helpful

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

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


when you execute two or mor commands you must seperate them
try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜