RE: [PHP] formatting "host" output
| From: | Matthew Loff | Date: | Mon, 23 Jul 2001 04:49:24 +0000 |
| Subject: | RE: [PHP] formatting "host" output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59121@lists.php.net to get a copy of this message | ||
If $lookup is passed from the client, then you should be careful with
that exec() call...
http://www.php.net/manual/en/ref.exec.php
Use one of the escape...() functions, perhaps?
-----Original Message-----
From: David Robley [mailto:huntsman@www.nisu.flinders.edu.au]
Sent: Monday, July 23, 2001 12:47 AM
To: Tyler Longren; php-general
Subject: Re: [PHP] formatting "host" output
On Sat, 21 Jul 2001 06:32, Tyler Longren wrote:
> $data = exec("host $lookup");
> printf("<pre>%s</pre>", $data);
>
> How can I format the output of that properly?
> Sometimes, it's all on one line, and it's fine.
> Other times, there's more than one line...like if there was an alias.
>
> Any way to format it like it is on the command line?
>
> Thanks,
> Tyler
$data = exec("host $lookup", $ary);
while(list(,$val) = each($ary)) {
echo $val . '<BR>';
}
You need to assign the output of exec to an array if you want to capture
multiple lines of output. Check the manual for more detail.
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
Try our NEW *SOLAR POWERED* tanning salon!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net To
contact the list administrators, e-mail: php-list-admin@lists.php.net