note 79122 rejected from function.shell-exec by betz

From: Date: Mon, 12 Nov 2007 19:27:42 +0000
Subject: note 79122 rejected from function.shell-exec by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132208@lists.php.net to get a copy of this message
Note Submitter: zhvihti at yahoo dot com ---- 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.

« previous php.notes (#132208) next »