[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [MacPerl] How to get the TCP/IP host name
>>gethostbyname('localhost'); # OK on Win32, not Linux
>
>Works on a Mac, at least in part, assuming you know what to expect from the
>return value. In a scalar context, returns the IP address as a packed 4
>character string.
Used it in array context on Win32, and it gives the full host name in first element. What does it give in array context on a Mac? (On Linux, it just stupidly gives 'localhost.localdomain')
>I thought this might be used with gethostbyaddr to get the host name as
>well, but I was unable to get that to work in under 5 minutes.
As I understand it, this uses reverse lookup, which is not always configured. So I wouldn't expect it to be reliable.
>>`hostname` # OK on Linux, not Win32
>
>Works in a Mac.
>
Really? Sounds great. On any Mac (with Perl)? Or just on some Macs which have installed some additional Unix tools or such?
>>$ENV{'HOSTNAME'} # OK on Linux, not Win32
>
>Doesn't work on a Mac in the sense of giving you the hostname, but that's
>sort of expected. It is my understanding that this is not guaranteed to
>work on a *nix system either.
Yes, I was considering this as a last resort only, once everything else has failed.
Thank you for your help.
===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org