How do I find out my hostname/domainname/IP address? The normal way to find your own hostname is to call the `hostna +me` program. While sometimes expedient, this has some problems, such as not knowing + whether you've got the canonical name or not. It's one of those tradeoffs of convenience ver +sus portability. The Sys::Hostname module (part of the standard perl distributio +n) will give you the hostname after which you can find out the IP address (assuming you have working + DNS) with a gethostbyname() call. use Socket; use Sys::Hostname; my $host = hostname(); my $addr = inet_ntoa(scalar gethostbyname($host || 'localho +st'));
Cheers,
Darren :)
In reply to Re: Getting the system ip address
by McDarren
in thread Getting the system ip address
by paranoid times
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |