|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-22 03:12 UTC] o dot kuhl at gmx dot 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
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? TorbenYes, I know the difference. That's why I tried several ways (with/without quotation marks, with stripslashes($command), with/without escaped spaces ('\ ') ), but it didn't work. I asked several colleagues for advice (PHP and Linux-Freaks), but we found no solution. But tell me: Does the script work on your system? Maybe I have an error in my configuration.... Greets, Oliver.please compile this little C program 'argdump' ---8<----- argdump.c -------------------------------- #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int i; for(i=0;i<argc;i++) printf("%d: %s\n",i,argv[i]); return EXIT_SUCCESS; } ---------------------------------------->8----------- and try the following PHP script (with argdump in $PATH) ---8<----- test.php -------------------------------- <?php function do_exec($cmd) { $res=array(); exec($cmd,$res); echo "\n\n$cmd\n"; print_r($res); } do_exec("argdump -h whois.denic.de Penelope\ Cruz"); do_exec("argdump -h whois.denic.de \"Penelope\ Cruz\""); do_exec("argdump -h whois.denic.de \"Penelope Cruz\""); do_exec("argdump -h whois.denic.de 'Penelope\ Cruz'"); do_exec("argdump -h whois.denic.de ".'"'."Penelope Cruz".'"'); ?> ---------------------------------------->8----------- my results are: argdump -h whois.denic.de Penelope\ Cruz Array ( [0] => 0: argdump [1] => 1: -h [2] => 2: whois.denic.de [3] => 3: Penelope Cruz ) argdump -h whois.denic.de "Penelope\ Cruz" Array ( [0] => 0: argdump [1] => 1: -h [2] => 2: whois.denic.de [3] => 3: Penelope\ Cruz ) argdump -h whois.denic.de "Penelope Cruz" Array ( [0] => 0: argdump [1] => 1: -h [2] => 2: whois.denic.de [3] => 3: Penelope Cruz ) argdump -h whois.denic.de 'Penelope\ Cruz' Array ( [0] => 0: argdump [1] => 1: -h [2] => 2: whois.denic.de [3] => 3: Penelope\ Cruz ) argdump -h whois.denic.de "Penelope Cruz" Array ( [0] => 0: argdump [1] => 1: -h [2] => 2: whois.denic.de [3] => 3: Penelope Cruz ) on *both* linux (SuSE 7.3) and Solaris (SunOS 5.5.1 and 5.7)Hartmut, you should reread the bug report. Oliver, I'm reopening this and reclassifying it as a Documentation Problem. When safe_mode is on, the arguments are passed through a function which escapes potentially dangerous characters--including the quote characters. However, this behaviour does not appear to be documented anywhere. When I enable safe_mode, I get the result you describe. However, when I remove the quotes and use this: exec('whois -h whois.denic.de Dirk Janssen', $output); ...I get the proper result on line 14: [14] => % No entries found for the selected source: "Dirk Janssen" I take it you don't get the right result from an authorized server? TorbenYou got it! When I disable the safe_mode, the following works: exec('whois -h whois.denic.de "Dirk Janssen"',$output); The little c-prog returns now (safe-mode off) the right output. But please tell me: Is it possible to execute a command like this whois-call in safe-mode? I don't get it to work! And if not, whats the solution? Thanx for the support, Oliver.