Bug #15157 Updated: exec()/system() doesn't work with parameters in quotation-marks in system-call

From: Date: Tue, 22 Jan 2002 09:01:38 +0000
Subject: Bug #15157 Updated: exec()/system() doesn't work with parameters in quotation-marks in system-call
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-77737@lists.php.net to get a copy of this message
ID: 15157 Comment by: o.kuhl@gmx.de Reported By: o.kuhl@gmx.de Status: Bogus Bug Type: Program Execution Operating System: Linux (Debian) / Solaris 8 PHP Version: 4.1.0 New Comment: I tried it, but with PHP I got an empty output from the system-call, which is the same with wrong parameters for the whois-function. I tried exactly the same script you posted. There is no difference from my experience. May there be a difference with Solaris/Debian/PHP4.1 and your setup? Please try "Dirk Janssen" in the whois-query, which returns a valid denic-result, BUT ONLY if you have a registered host for this query. I think it's a PHP-Bug, caus the call in the shell returns the right result. Greetings, Oliver. Previous Comments: ------------------------------------------------------------------------ [2002-01-22 03:20:22] hholzgra@php.net you have to use double \\ to pass a \ to the executing shell as \ is the php escape character, too ------------------------------------------------------------------------ [2002-01-22 03:20:21] torben@php.net I don't get anything weird on PHP 4.2.0-dev with this script: <?php error_reporting(E_ALL); exec('whois -h whois.denic.de "Penelope Cruz"', $output); print_r($output); ?> The above outputs the same thing as running the command at the prompt. What do you get from the above script? Torben ------------------------------------------------------------------------ [2002-01-22 03:12:55] o.kuhl@gmx.de The exec/system-Functions don't work with calls like this: whois -h whois.denic.de "Penelope Cruz" The problem is the string "Penelope Cruz", which has to be one parameter for the whois-function. Without quotation marks, the string is used as two parameters - even when they're connected with "\ " -> ("Penelope\ Cruz"). And with quotation marks, PHP executes the command with "Penelope Cruz" as one string, BUT WITH the quotation marks included. I tried several other ways (with system(), too), but none of them worked: exec("whois -h whois.denic.de Penelope\ Cruz"); exec("whois -h whois.denic.de \"Penelope\ Cruz\""); exec("whois -h whois.denic.de \"Penelope Cruz\""); exec("whois -h whois.denic.de 'Penelope\ Cruz'"); exec("whois -h whois.denic.de ".'"'."Penelope Cruz".'"'."); ... My config: './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-zlib=/usr' '--with-curl=/usr/local' '--with-mysql=/usr/local/mysql' '--with-ldap=/usr/local' '--with-openssl' '--enable-ftp' The problem was the same with Linux (Debian Potato) and Solaris8 Greets, Oliver. ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=15157&edit=1

« previous php.dev (#77737) next »