Chirag
Chirag

Reputation: 1929

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

Upvotes: 1

Views: 3850

Answers (3)

ratlink
ratlink

Reputation: 11

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");

Upvotes: 1

gsk
gsk

Reputation: 1685

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

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

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

Upvotes: 6

Related Questions