note 79122 added to function.shell-exec

From: Date: Mon, 12 Nov 2007 15:24:24 +0000
Subject: note 79122 added to function.shell-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-132205@lists.php.net to get a copy of this message
On Windows, neither shell_exec nor exec seem to work on files that contain both brackets "()" and spaces in the name. The system splits the command by the spaces, thinking of each chunk as a different parameter, resulting of course in a mess. E.g. trying to start an mp3 file in the following way: shell_exec('"C:\Audio (Nice).mp3"') would give you 'C:\Audio' is not recognized as an internal or external command, operable program or batch file. escapeshellcmd() and escapeshellarg() don't help. The first stupidly replaces the brackets with spaces; the second only adds the double quotes if they are not present. Solution is to use two double quotes on each end, like that: shell_exec('""C:\Audio (Nice).mp3""') I consider this a bug in PHP since it all works well from the command line itself. ---- Server IP: 83.137.20.135 Probable Submitter: 145.99.237.98 ---- Manual Page -- http://www.php.net/manual/en/function.shell-exec.php Edit -- https://master.php.net/note/edit/79122 Del: integrated -- https://master.php.net/note/delete/79122/integrated Del: useless -- https://master.php.net/note/delete/79122/useless Del: bad code -- https://master.php.net/note/delete/79122/bad+code Del: spam -- https://master.php.net/note/delete/79122/spam Del: non-english -- https://master.php.net/note/delete/79122/non-english Del: in docs -- https://master.php.net/note/delete/79122/in+docs Del: other reasons-- https://master.php.net/note/delete/79122 Reject -- https://master.php.net/note/reject/79122 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132205) next »