File: hostname.pl

package info (click to toggle)
tct 1.07-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,828 kB
  • ctags: 1,128
  • sloc: perl: 9,604; ansic: 4,861; makefile: 516; sh: 77
file content (22 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# file: hostname.pl
# usage: $hostname = &'hostname;
#
# purpose: get hostname -- try method until we get an answer 
#       or return "Amnesiac!"
#

require 'command.pl';
 
sub hostname {
    if (!defined $hostname) {
        $hostname =  ( -x '/bin/hostname'     && &command_to_string("/bin/hostname") ) 
                  || ( -x '/usr/ucb/hostname' && &command_to_string("/usr/ucb/hostname") )
                  || ( -x '/bin/uname'        && &command_to_string("/bin/uname -n") )
                  || ( -x '/usr/bin/uuname'   && &command_to_string("/usr/bin/uuname -l"))
                  || 'Amnesiac!'; 
    }
    $hostname;
}
 
1;