note 85930 added to function.exec

From: Date: Thu, 25 Sep 2008 03:21:44 +0000
Subject: note 85930 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-144692@lists.php.net to get a copy of this message
I was having trouble using the PHP exec command to execute any batch file. Executing other commands (i.e., "dir") works fine). But if I executed a batch file, I receieved no output from the exec command. The server setup I have consists of Windows Server 2003 server running IIS6 and PHP 5.2.3. On this server, I have: 1. Granted execute permissions to the Internet User on c:\windows\system32\cmd.exe. 2. Granted Everyone->Full Control to the directory in which the batch file is written. 3. Granted Everyone->Full Control on the entire c:\cygwin\bin directory and its contents. 4. Granted the Internet User "log on as batch" permissions. 5. Specified the full path to each file being executed. 6. Tested these scripts running from the command line on the server and they work just fine. 7. Ensured that %systemroot%\system32 is in the system path. It turns out that even with all of the above in place on the server, I had to specify the full path to cmd.exe in the exec call. When I used the call: $output = exec("c:\\windows\\system32\\cmd.exe /c $batchFileToRun"); then everything worked fine. In my situation, $batchFileToRun was the actual system path to the batch file (i.e., the result of a call to realpath()). ---- Server IP: 64.71.164.2 Probable Submitter: 68.50.61.232 ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- https://master.php.net/note/edit/85930 Del: integrated -- https://master.php.net/note/delete/85930/integrated Del: useless -- https://master.php.net/note/delete/85930/useless Del: bad code -- https://master.php.net/note/delete/85930/bad+code Del: spam -- https://master.php.net/note/delete/85930/spam Del: non-english -- https://master.php.net/note/delete/85930/non-english Del: in docs -- https://master.php.net/note/delete/85930/in+docs Del: other reasons-- https://master.php.net/note/delete/85930 Reject -- https://master.php.net/note/reject/85930 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144692) next »