ID: 15157
Updated by: hholzgra
Old Summary: exec()/system() doesn't work with parameters in
quotation-marks in system-call
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Program Execution
Operating System: Linux (Debian) / Solaris 8
PHP Version: 4.1.0
New Comment:

you know the difference between exec() and system()?

exec() executes the given program passing the arguments
verbatim while system() creates a new shell process
and passes the command to the shell for execution

with exec you have no argument processing like
wildcard matching and things at all so your
quote characters will stay in the input






Previous Comments:
------------------------------------------------------------------------

[2002-01-22 04:47:37] [EMAIL PROTECTED]

I did cut an paste your Script. On the Debian-System (which is not
authorized @denic to search for a person) it returns on line 14:

% No entries found for the selected source: ""Dirk Janssen""

It seems as if the quotation marks are passed thru. When I call the
command on the shell, it returns (line 14 again):

% No entries found for the selected source: "Dirk Janssen"

Watch the quotation marks! And that's the problem (maybe a bug) I
think. The result in the shell is ok, since the host is not authorized
to search for people.
On the authorized solaris-box, the whois-call on the shell returns the
DENIC-Handle, etc.
The exec()-call (your cut'n'pasted script with "Dirk Janssen" as
searchstring) returns nothing. If I try it with "test.de", which
returns the info for the domain on the shell-call, the PHP-Script
returns the well-known output on line 14:

% No entries found for the selected source: ""test.de""

Once again, PHP seems to have a problem with the quotation-marks.

Ok, there is a difference: The quotation marks should not be passed
through to the whois-command. What whois needs is a parameter which has
the string 'Dirk Janssen' as value. PHP seems to send the string with
the quotation-marks - or when I try it without them - as two separated
parameters to the whois-function. Even if I try to connect the two
words with an '\ ' (escaped space). By the way, the escaped space works
on the shell:

shell> whois -h whois.denic.de Dirk\ Janssen

I don't know. I now do the whois-query through the socket, which is a
much better way then the exec()-alternative. But there must be a way to
do it with the exec()-command.....

Oliver.

------------------------------------------------------------------------

[2002-01-22 04:11:39] [EMAIL PROTECTED]

I'm running Debian here. Can you actually cut and paste
the script I posted before, and try it? The lines you posted
before wouldn't actually produce any output, which is why
I'm wondering...

Torben

------------------------------------------------------------------------

[2002-01-22 04:01:37] [EMAIL PROTECTED]

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.

------------------------------------------------------------------------

[2002-01-22 03:20:22] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/?id=15157


Edit this bug report at http://bugs.php.net/?id=15157&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to