Sys::Utmp - access to Utmp entries on Unix-like system

NAME

Sys::Utmp - access to Utmp entries on Unix-like system

SYNOPSIS


    use Sys::Utmp;

    my $u = Sys::Utmp.new;

    for $u.list.grep(UserProcess) -> $ent {
        say $ent;
    }

METHODS

method getutent

This returns the successive Sys::Utmp::Utent each time it is called until it has exhausted the records when it will return an undefined object.

method setutent

This will reset the file pointer maintained by getutent to the begining so the file can be read again.

method endutent

This closes the utmp file and free any resources acquired by getutent

method utmpname

Set the file to be read to something other than the default, this should not be necessary but some systems may place the file in a non-standard location.

method list

This will return the list of Sys::Utmp::Utent objects that would be obtained if getutent was called repeatedly but is somewhat lazy if all the records aren't required.

Sys::Utmp::Utent

user

Returns the use this record was created for if this is a record for a user process. Some systems may return other information depending on the record type. If no user was set this will be the empty string.

id

The identifier for this record - it might be the inittab tag or some other system dependent value.

line

For user process records this will be the name of the terminalor line that the user is connected on.

pid

The process ID of the process that created this record.

type

The type of the record this will have a value corresponding to one of the constants (not all of these may be available on all systems and there may well be others which should be described in the getutent manpage or in /usr/include/utmp.h ) :

The enum UtmpType defines the constants as:

  • Accounting - record was created for system accounting purposes.

  • BootTime - the record was created at boot time.

  • DeadProcess - The process that created this record has terminated.

  • EmptyRecord - record probably contains no other useful information.

  • InitProcess - this is a record for process created by init.

  • LoginProcess - this record was created for a login process (e.g. getty).

  • NewTime - record created when the system time has been set.

  • OldTime - record recording the old tme when the system time has been set.

  • RunLevel - records the time at which the current run level was started.

  • UserProcess - record created for a user process (e.g. a login )

Some systems don't define all of these, in these cases they are defined with a value that is never usedl

An object of Sys::Utmp::Utemp can be smart matched to this values to select for items of a certain type.

host

On systems which support this the method will return the hostname of the host for which the process that created the record was started - for example for a telnet login.

tv

The time in epoch seconds wt which the record was created.

timestamp

This returns a DateTime that corresponds to tv

Sys::Utmp v0.1.1

Raku access to Utmp entries on Unix-like systems

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Sys::Utmp

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.