1Sys::Info::OS(3)      User Contributed Perl Documentation     Sys::Info::OS(3)
2
3
4

NAME

6       Sys::Info::OS
7

VERSION

9       version 0.7807
10

SYNOPSIS

12          use Sys::Info;
13          my $info = Sys::Info->new;
14          my $os   = $info->os(%options);
15
16       or
17
18          use Sys::Info::OS;
19          my $os = Sys::Info::OS->new(%options);
20
21       Example:
22
23          use Data::Dumper;
24
25          warn "Collected information can be incomplete\n" if $os->is_unknown;
26
27          my %fs = $os->fs;
28          print Data::Dumper->Dump([\%fs], ['*FILE_SYSTEM']);
29
30          print "B1ll G4teZ rull4z!\n" if $os->is_windows;
31          print "Pinguin detected!\n"  if $os->is_linux;
32          if ( $os->is_windows ) {
33             printf "This is a %s based system\n", $os->is_winnt ? 'NT' : '9.x';
34          }
35          printf "Operating System: %s\n", $os->name( long => 1 );
36
37          my $user = $os->login_name( real => 1 ) || $os->login_name || 'User';
38          print "$user, You've Got The P.O.W.E.R.!\n" if $os->is_root;
39
40          if ( my $up = $os->uptime ) {
41             my $tick = $os->tick_count;
42             printf "Running since %s\n"   , scalar localtime $up;
43             printf "Uptime: %.2f hours\n" , $tick / (60*60      ); # probably windows
44             printf "Uptime: %.2f days\n"  , $tick / (60*60*24   ); # might be windows
45             printf "Uptime: %.2f months\n", $tick / (60*60*24*30); # hmm... smells like tux
46          }
47

DESCRIPTION

49       Supplies detailed operating system information.
50

NAME

52       Sys::Info::OS - Detailed os information.
53

METHODS

55   new
56       Object constructor.
57
58   name
59       Returns the OS name. Supports these named parameters: "edition",
60       "long":
61
62          # also include the edition info if present
63          $os->name( edition => 1 );
64
65       This will return the long OS name (with build number, etc.):
66
67          # also include the edition info if present
68          $os->name( long => 1, edition => 1 );
69
70   version
71       Returns the OS version.
72
73   build
74       Returns the OS build number or build date, depending on the system.
75
76   uptime
77       Returns the uptime as a unix timestamp.
78
79   tick_count
80       Returns the uptime in seconds since the machine booted.
81
82   node_name
83       Machine name
84
85   domain_name
86       Returns the network domain name.
87
88       Synonyms:
89
90       workgroup
91
92   login_name
93       Returns the name of the effective user. Supports parameters in "name =>
94       value" format. Accepted parameters: "real":
95
96           my $user = $os->login_name( real => 1 ) || $os->login_name;
97
98   ip
99       Returns the IP number.
100
101   fs
102       Returns an info hash about the filesystem. The contents of the hash can
103       vary among different systems.
104
105   host_name
106   time_zone
107   product_type
108   bitness
109       If successful, returns the bitness ( 32 or 64 ) of the OS. Returns
110       false otherwise.
111
112   meta
113       Returns a hash containing various informations about the OS.
114
115   cdkey
116   locale

UTILITY METHODS

118       These are some useful utility methods.
119
120   is_windows
121       Returns true if the os is windows.  Synonyms:
122
123       is_win32
124       is_win
125
126   is_winnt
127       Returns true if the OS is a NT based system (NT/2000/XP/2003).
128
129       Always returns false if you are not under windows or you are not under
130       a NT based system.
131
132   is_win95
133       Returns true if the OS is a 9x based system (95/98/Me).
134
135       Always returns false if you are not under Windows or Windows9x.
136
137       Synonyms:
138
139       is_win9x
140
141   is_linux
142       Returns true if the os is linux.  Synonyms:
143
144       is_lin
145
146   is_bsd
147       Returns true if the os is (free|open|net)bsd.
148
149   is_unknown
150       Returns true if this module does not support the OS directly.
151
152   is_root
153       Returns true if the current user has admin rights.  Synonyms:
154
155       is_admin
156       is_admin_user
157       is_adminuser
158       is_root_user
159       is_rootuser
160       is_super_user
161       is_superuser
162       is_su
163

CAVEATS

165       •   I don't have access to all operating systems in the world, so this
166           module (currently) only supports Windows, Linux and (Free)BSD.
167           Windows support is better.  If you want support for some other OS,
168           you'll need to write the driver yourself. Anything other than
169           natively supported systems will fall-back to the generic "Unknown"
170           driver which has very limited capabilities.
171
172Win32::IsAdminUser() implemented in 5.8.4 (However, it is possible
173           to manually upgrade the "Win32" module). If your ActivePerl is
174           older than this, "is_admin" method will always returns false.
175           (There may be a workaround for that).
176
177       •   Contents of the filesystem hash may change in further releases.
178
179       •   Filesystem [Windows]
180
181           File system information can not be extracted under restricted
182           environments. If this is the case, we'll get an access is denied
183           error.
184
185       •   Bitness has some problems [Linux, BSD], especially on the os side.
186

SEE ALSO

188       Win32, POSIX, Sys::Info, Sys::Info::Device,
189       <http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp>.
190

AUTHOR

192       Burak Gursoy <burak@cpan.org>
193
195       This software is copyright (c) 2006 by Burak Gursoy.
196
197       This is free software; you can redistribute it and/or modify it under
198       the same terms as the Perl 5 programming language system itself.
199
200
201
202perl v5.34.0                      2021-07-22                  Sys::Info::OS(3)
Impressum