通过 PHP 执行命令的帮助

发布于 2024-10-15 07:55:32 字数 591 浏览 3 评论 0原文

我正在尝试运行 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
?>

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

阪姬 2024-10-22 07:55:32

exec 调用中的内容与命令注释中的内容不同。您删除了命令及其参数周围的引号。它们可能很重要。

缺少引号

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.

missing quotes

ぃ双果 2024-10-22 07:55:32

在 Windows 中,exec() 发出对“cmd /c your_command”的内部调用。这意味着您的命令必须遵循 cmd.exe 施加的规则,其中包含完整命令周围的一组额外引号。希望这些链接会有帮助

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

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

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

凤舞天涯 2024-10-22 07:55:32

当您执行两个或更多命令时,必须将它们分开
试试这个:

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

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");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文