summaryrefslogtreecommitdiffstats
path: root/ldap/admin/src/uname.lib
blob: bef5219de2781a894415e5c872c8d6fa85a2f915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!perl
#
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

sub uname
{
  local (@CommandLine) = @_;

  local($getall) = 0;
  local($getproc) = 0;
  local($getosrel) = 0;
  local($getosname) = 0;
  local($getosver) = 0;

  while ($_ = @CommandLine[0]) {
    PARSE_SWITCH: {
      if (/^-a\b/i) {# show all information
        $getall=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      if (/^-n\b/i) {# show node name
        $getnodename=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      if (/^-p\b/i) {# show processor
        $getproc=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      if (/^-r\b/i) {# show os release
        $getosrel=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      if (/^-s\b/i) {# show os name
        $getosname=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      if (/^-v\b/i) {# show os version
        $getosver=1;
        shift(@CommandLine);
        last PARSE_SWITCH
      }
      print "   ERROR: Unknown parameter: $_\n";
      shift(@CommandLine);
    }
  }

chomp(local($os) = `uname -s`);
local($nodename) = "";
local($proc) = "";
local($osrel) = "";
local($osname) = "";
local($osver) = "";
local($osrel1) = "";
local($osrel2) = "";
local($nodename1) = "";
local($retval) = "";
local($ret) = "";

if ($os eq "Windows_NT")
{
  chomp($nodename = `uname -n`); 
  chomp($proc = `uname -m`); lc($proc);
  if ($proc =~ /^[0-9]86.*/)
  {
    $proc = "i386";
  }
  else
  {
    $proc = "?";
  }
  chomp($osrel1 = `uname -r`);
  chomp($osrel2 = `uname -v`);
  $osrel = $osrel1.".".$osrel2;
  $osname = "WINNT";
  $osver = "???";
}
if ($os eq "WINNT")
{
  chomp($nodename = `uname -n`);
  chomp($proc = `uname -p`); lc($proc);
  chomp($osrel = `uname -r`);
  $osname = "WINNT";
  chomp($osver = `uname -v`);
} 

if ($os eq "SunOS")
{
  chomp($nodename = `uname -n`);
  chomp($proc = `uname -p`);
  chomp($osrel = `uname -r`);
  $osname = $os;
  chomp($osver = `uname -v`);
}
if ($os eq "IRIX" || $os eq "IRIX64")
{
  chomp($nodename = `uname -n`);
  chomp($proc = `uname -p`);
  chomp($osrel = `uname -r`);
  $osname = "IRIX";
  chomp($osver = `uname -v`);
}

if ($os eq "HP-UX")
{
  chomp($nodename = `uname -n`);
#  $proc = "hppa1.1";
  chomp($proc = `uname -m`);
  chomp($osrel = `uname -r`);
  $osname = $os;
  chomp($osver = `uname -v`);
}

if ($os eq "OSF1")
{
  chomp($nodename1 = `uname -n`);
  ($nodename) = ($nodename1 =~ /(\w+)\..*/);
  chomp($proc = `uname -m`);
  chomp($osrel = `uname -r`);
  $osname = $os;
  chomp($osver = `uname -v`);
}

if ($os eq "AIX")
{
  chomp($nodename = `uname -n`);
  $proc = "rs6000";
  chomp($osrel1 = `uname -v`);
  chomp($osrel2 = `uname -r`);
  $osrel = $osrel1.".".$osrel2;
  $osname = $os;
  $osver = "???";
}

if ($getall)
{
  $getosname = 1;
  $getnodename = 1;
  $getosrel = 1;
  $getosver = 1;
  $getproc = 1;
}

$retval = "";
$retval = $retval.($getosname ?		$osname :		"");
$retval = $retval.($getnodename ?	" ".$nodename :		"");
$retval = $retval.($getosrel ?		" ".$osrel :		"");
$retval = $retval.($getosver ?		" ".$osver :		"");
$retval = $retval.($getproc ?		" ".$proc :		"");

if ($retval eq "")
{
  $retval = $nodename;
}

($ret) = ($retval =~ /\s*(.*)/);

return "$ret";
}
1