note 88708 added to function.system

From: Date: Wed, 04 Feb 2009 12:35:14 +0000
Subject: note 88708 added to function.system
Groups: php.notes 
Request: Send a blank email to php-notes+get-150199@lists.php.net to get a copy of this message
The real culprit behind all these double quote thing is usage of cmd.exe inside PHP process execution functions. To verify, just try executing any command lines (with multiple pairs of double quotes) prefixed with "cmd.exe /c" , and you'll see that particular error message. Yes, without the "cmd.exe /c", everything function normally. Concerning the trick mentioned by tceverling: <?php system('[useless command] & [desired command]'); ?> The reason it works is mainly attributed to the "&", which effectively rendered "cmd /c" useless, thus only executing desired command. There are 2 more methods (other than using batch file) that I've written on my blog (http://me.abelcheung.org/2009/01/19/), but I suppose it's better to describe them briefly here: 1. Quoting the whole command, including all double quotes, with yet another level of double quotes. The original double quotes don't need to be escaped. 2. Abandon all other functions and use proc_open() with bypass_shell option for all process execution. That's absolutely PAIN IN THE ASS. I wonder why PHP developers decided to use cmd /c. ---- Server IP: 58.65.236.81 Probable Submitter: 218.103.6.116 ---- Manual Page -- http://www.php.net/manual/en/function.system.php Edit -- https://master.php.net/note/edit/88708 Del: integrated -- https://master.php.net/note/delete/88708/integrated Del: useless -- https://master.php.net/note/delete/88708/useless Del: bad code -- https://master.php.net/note/delete/88708/bad+code Del: spam -- https://master.php.net/note/delete/88708/spam Del: non-english -- https://master.php.net/note/delete/88708/non-english Del: in docs -- https://master.php.net/note/delete/88708/in+docs Del: other reasons-- https://master.php.net/note/delete/88708 Reject -- https://master.php.net/note/reject/88708 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150199) next »