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

NAME

6       Sys::Info::OS - Detailed os information.
7

SYNOPSIS

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

DESCRIPTION

46       This document describes version 0.7804 of "Sys::Info::OS" released on
47       "21 January 2015".
48
49       Supplies detailed operating system information.
50

METHODS

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

UTILITY METHODS

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

CAVEATS

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

SEE ALSO

185       Win32, POSIX, Sys::Info, Sys::Info::Device,
186       <http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp>.
187

AUTHOR

189       Burak Gursoy <burak@cpan.org>.
190
192       Copyright 2006 - 2015 Burak Gursoy. All rights reserved.
193

LICENSE

195       This library is free software; you can redistribute it and/or modify it
196       under the same terms as Perl itself, either Perl version 5.16.2 or, at
197       your option, any later version of Perl 5 you may have available.
198
199
200
201perl v5.28.0                      2018-07-15                  Sys::Info::OS(3)
Impressum