home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
c
/
cops_104.zip
/
cops_104
/
perl
/
hostname.pl
< prev
next >
Wrap
Perl Script
|
1992-03-10
|
475b
|
23 lines
#
# file: hostname.pl
# usage: $hostname = &'hostname;
#
# purpose: get hostname -- try method until we get an answer
# or return "Amnesiac!"
#
package hostname;
sub main'hostname {
if (!defined $hostname) {
$hostname = ( -x '/bin/hostname' && `/bin/hostname` )
|| ( -x '/bin/uname' && `/bin/uname -n` )
|| ( -x '/usr/bin/uuname' && `/usr/bin/uuname -l`)
|| 'Amnesiac! '; # trailing space is for chop
chop $hostname;
}
$hostname;
}
1;