More robust yacc/bison failure output handling.
[p5sagit/p5-mst-13.2.git] / lib / hostname.pl
CommitLineData
463ee0b2 1# From: asherman@fmrco.com (Aaron Sherman)
2
3sub hostname
4{
5 local(*P,@tmp,$hostname,$_);
6 if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
7 {
8 chop($hostname = $tmp[$#tmp]);
9 }
10 elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
11 {
12 chop($hostname = $tmp[$#tmp]);
13 }
14 else
15 {
16 die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
17 }
18 @tmp = ();
19 close P; # Just in case we failed in an odd spot....
20 $hostname;
21}
22
231;