16. System Information
Contents:
16.1 Getting User and Machine InformationPerl provides several facilities for finding out information about the user and machine that you are running on. These functions are provided via Win32 extensions (see Appendix B, Libraries and Modules , for more information).
To retrieve the name of the user executing the script, use the use Win32; $name = Win32::LoginName;
To retrieve the name of the machine executing the script, use the use Win32; $machine = Win32::NodeName;
The use Win32::NetAdmin; $user = Win32::LoginName; # grab the name of the current user Win32::NetAdmin::UserGetAttributes("", $username, $password, $passwordage, $privilege, $homedir, $comment, $flags, $scriptpath); print "The homedir for $username is $homedir\n";
For more information on using As you explore Perl scripts on the Net, you'll no doubt find scripts that refer to any of a myriad of Perl functions that access UNIX password and group files. At the time of this writing, these functions are not implemented in Perl on Win32 platforms, but you can usually duplicate the functionality (if it's applicable) using one of the Win32 extension modules. |
|