"tailing" utmp(x)?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I know how to read and "tail" the Utmp files on the systems I have
access to.  We now have OSX machines that are using the Utmpx system
and the records are not as straight forward to read.

I am looking at the User::Utmp modure since it will handle either type
of file.  However it appears that it will read in the WHOLE Utmp(x)
file at one time and then hand the caller an array of hashes that
represents the file.

There is nothing wrong with that except I need to constantly be made
aware of new Utmp(x) entries as they appear.  Closing and reopening
the Utmp(x) file and re-reading to to pull in a possible new couple of
lines seems very wasteful.

Do you have ideas?

Re: "tailing" utmp(x)?

Quoted text here. Click to load it

Yes, that's right.

Quoted text here. Click to load it

Well, it's not particularly clever, either ;-) (as the author I can say

Quoted text here. Click to load it

The utmpx file format is opaque and the file may only be accessed using
the corresponding functions (getutxline(), etc.)  Thus, the question is
whether it works reliably to call getutxent() in an infinite loop to get
newly added records.  I haven't tried this yet.  However, getutxent()
returns NULL both on failure and at the end of the database, so it would
not be possible to detect errors.


Public key at <http://www.dynalabs.de/mxp/pubkey.txt (ID 0x1614A044)

Site Timeline