{
    "mode": "perldoc",
    "parameter": "Sys::Utmp",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Sys%3A%3AUtmp/json",
    "generated": "2026-06-12T14:14:36Z",
    "synopsis": "use Sys::Utmp;\nmy $utmp = Sys::Utmp->new();\nwhile ( my $utent =  $utmp->getutent() )\n{\nif ( $utent->userprocess )\n{\nprint $utent->utuser,\"\\n\";\n}\n}\n$utmp->endutent;\nSee also examples/pwho in the distribution directory.",
    "sections": {
        "NAME": {
            "content": "Sys::Utmp - Object(ish) Interface to UTMP files.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Sys::Utmp;\n\nmy $utmp = Sys::Utmp->new();\n\nwhile ( my $utent =  $utmp->getutent() )\n{\nif ( $utent->userprocess )\n{\nprint $utent->utuser,\"\\n\";\n}\n}\n\n$utmp->endutent;\n\nSee also examples/pwho in the distribution directory.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Sys::Utmp provides a vaguely object oriented interface to the Unix user accounting file (\nsometimes /etc/utmp or /var/run/utmp). Whilst it would prefer to use the getutent() function\nfrom the systems C libraries it will attempt to provide its own if they are missing.\n\nThis may not be the module that you are looking for - there is a User::Utmp which provides a\ndifferent procedural interface and may well be more complete for your purposes.\n\nMETHODS\nnew The constructor of the class. Arguments may be provided in Key => Value pairs : it currently\ntakes one argument 'Filename' which will set the file which is to be used in place of that\ndefined in PATHUTMP.\n\ngetutent\nIterates of the records in the utmp file returning a Sys::Utmp::Utent object for each record\nin turn - the methods that are available on these objects are descrived in the\nSys::Utmp::Utent documentation. If called in a list context it will return a list containing\nthe elements of th Utent entry rather than an object. If the import flag ':fields' is used\nthen constants defining the indexes into this list will be defined, these are uppercase\nversions of the methods described in Sys::Utmp::Utent.\n\nsetutent\nRewinds the file pointer on the utmp filehandle so repeated searches can be done.\n\nendutent\nCloses the file handle on the utmp file.\n\nutmpname SCALAR filename\nSets the file that will be used in place of that defined in PATHUTMP. It is not defined\nwhat will happen if this is done between two calls to getutent() - it is recommended that\nendutent() is called first.\n\nEXPORT\nNo methods or constants are exported by default.\n",
            "subsections": [
                {
                    "name": "Exportable constants",
                    "content": "These constants are exportable under the tag ':constants':\n\nACCOUNTING\nBOOTTIME\nDEADPROCESS\nEMPTY\nINITPROCESS\nLOGINPROCESS\nNEWTIME\nOLDTIME\nRUNLVL\nUSERPROCESS\n\nThese are the values that will be found in the uttype field of the Sys::Utmp::Utent object.\n\nThese constants are exported under the tag ':fields' :\n\nUTUSER\nUTID\nUTLINE\nUTPID\nUTTYPE\nUTHOST\nUTTIME\n\nThese provide the indexes into the list returned when \"getutent\" is called in list context.\n"
                }
            ]
        },
        "BUGS": {
            "content": "Probably. This module has been tested on Linux, Solaris, FreeBSD ,SCO Openserver and SCO\nUnixWare and found to work on those platforms. If you have difficulty building the module or it\ndoesnt behave as expected then please contact the author including if appropriate your\n/usr/include/utmp.h\n\nPatches to make this work better on any platform are always welcome. The source is managed at\nhttps://github.com/jonathanstowe/Sys-Utmp so feel free to fork and send a pull request.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Jonathan Stowe, <jns@gellyfish.co.uk>\n",
            "subsections": []
        },
        "LICENCE": {
            "content": "This Software is Copyright Netscalibur UK 2001, Jonathan Stowe 2001-2013\n\nThis Software is published as-is with no warranty express or implied.\n\nThis is free software and can be distributed under the same terms as Perl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "perl. Sys::Utmp::Utent\n",
            "subsections": []
        }
    },
    "summary": "Sys::Utmp - Object(ish) Interface to UTMP files.",
    "flags": [],
    "examples": [],
    "see_also": []
}