Hi,
Tuesday, July 29, 2003, 3:11:43 AM, you wrote:
CZ> * Thus wrote Tom Rogers ([EMAIL PROTECTED]):
>> Hi,
>>
>> Monday, July 28, 2003, 4:29:46 PM, you wrote:
>> >>Try this:
>> >><?php
>> >>exec('ipconfig',$catch);
>> >>foreach($catch as $line){
>> >> if(eregi('IP Address',$line)){
>> >> list($t,$ip) = split(':',$line);
>> >> echo 'IP is '.$ip."\n";
CZ> btw, the $ip needs to be trimmed it actually contains a space at
CZ> this point ' XXX.XXX.XXX.XXX'
>> >> }
>> >>}
>> >>?>
>>
>> CL> Thanks Tom, but I think it only work for Win NT, how about Win 9x?
>>
>>
>> There is ipconfig.exe in win98 SE thats about all I know.
CZ> win98 has that command. when I issue that on my computer I get
CZ> multiple interfaces back something like:
CZ> interface 0:
CZ> [interface data]
CZ> interface 1:
CZ> [interface data]
CZ> So the above code wont guarantee the correct IP address.
CZ> Curt
CZ> --
CZ> "I used to think I was indecisive, but now I'm not so sure."
Here is a modified version to eliminate the first entry as it is
0.0.0.0. If you have more than one interface you will have to store
them in an array.
exec('ipconfig /all',$catch);
foreach($catch as $line){
if(eregi('IP Address',$line)){
list($t,$ip) = split(':',$line);
$ip = trim($ip);
if(ip2long($ip > 0)){
echo 'IP is '.$ip."\n";
}
}
}
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php