This little snippet shows how to parse /var/adm/wtmpx in
Solaris (tested on Solars 7 only). I did this as an
excercise in using the "unpack" function, and why not
share in with the rest of the world. Maybe someone can
use it.
#
# Instead of @data, one could assign separate variables
# like this:
#
# ($user,$id,$line,$pid,$type,$exit_1,$exit_2,$tv_1,
# $tv_2,$session,$pad_1,$pad_2,$pad_3,$pad_4,$pad_5,
# $syslen,$host) = unpack(...);
#
open(FD,"</var/adm/wtmpx") or die;
my $wtmpx;
my @data;
while(read(FD,$wtmpx,372)) {
@data = unpack('A32 A4 A32 l s ss xx ll l lllll s A257', $wtmpx);
# Do things!
}
close(FD);