/
uname
executable file
·104 lines (64 loc) · 1.42 KB
/
uname
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
#!/usr/bin/perl
=begin metadata
Name: uname
Description: print system information
Author: Jeffrey S. Haemer
License: perl
=end metadata
=cut
use POSIX "uname";
use strict;
use Getopt::Std;
use vars qw($opt_s $opt_n $opt_r $opt_v $opt_m $opt_a);
my $usage = "usage: uname [-snrvma]\n";
getopts "snrvma" or die $usage;
my ($sysname, $nodename, $release, $version, $machine ) = uname;
my @out = ();
if ($opt_s || $opt_a) {
push @out, $sysname;
}
if ($opt_n || $opt_a) {
push @out, $nodename;
}
if ($opt_r || $opt_a) {
push @out, $release;
}
if ($opt_v || $opt_a) {
push @out, $version;
}
if ($opt_m || $opt_a) {
push @out, $machine;
}
push @out, $sysname unless @out;
print "@out\n";
=head1 NAME
uname - print system information
=head1 SYNOPSIS
uname [-snrvma]
=head1 DESCRIPTION
uname prints out system identification information.
It's really just a front end for the system call B<uname(2)>.
=head1 OPTIONS AND ARGUMENTS
=over 2
=item I<-s>
system
=item I<-n>
network node name
=item I<-r>
operating system release
=item I<-v>
operating system version
=item I<-m>
machine type
=item I<-a>
All of the above.
=back
Multiple arguments print all information requested,
but always in the order "snrvma".
=head1 AUTHOR
Jeffrey S. Haemer
=head1 BUGS
There is no standard definition of what actually belongs in these fields.
What are acceptable values for, for example, "machine type"?
=head1 SEE ALSO
uname(2)