?
Solved

Need to display YEAR data from Solaris wtmpx file contents

Posted on 2007-03-21
4
Medium Priority
?
857 Views
Last Modified: 2013-12-27
I need a Solaris solution to produce "last" output (run against wtmpx) that displays YEAR data as well as month, day & time. Standard "last" output does not include YEAR data. Can someone help? Thanks!
0
Comment
Question by:pzxkys
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 1000 total points
ID: 18767490
The following script may serve your needs.  It doesn't provide all the options of the 'last' command, but it wouldn't be too difficult to change it.

#!/usr/bin/perl
use strict;

my $template = "A32 A4 A32 l s s2 x2 l2 l x20 s A257 x";
my $recordsize = length(pack($template,()));
open WTMPX,"/var/adm/wtmpx" or die "Unable to open wtmpx:$!\n";

my $record;

while (read(WTMPX,$record,$recordsize)) {
  my ($ut_user,$ut_id,$ut_line,$ut_pid,$ut_type,$ut_e_termination,$ut_e_exit,$tv_sec,$tv_usec,$ut_session,$ut_syslen,$ut_host)= unpack($template,$record);
  printf("%-9s %10s %s\n",$ut_user, $ut_line, scalar localtime($tv_sec)) if ($ut_user =~ /^[a-z]/);
}

close WTMPX;
0
 
LVL 38

Expert Comment

by:yuzh
ID: 18768386
last command on Solaris systems doesn't report the year included in its records,

please have a look at the answer in http:Q_21890379.html  for workarounds.
0
 

Author Comment

by:pzxkys
ID: 18770439
I believe Tintin's answer solves my problem. Just one follow-up question please. Is Perl a standard piece of all Solaris releases now? I see it on Solaris 8 , 9 and Solaris 10 systems that I examined this morning. Not sure if we have any Solaris 7 systems around ... but we may ...
0
 

Author Comment

by:pzxkys
ID: 18770470
Thanks to Tintin and Vuzh for the response! I answered my own follow-up question. I found some doc that says "Starting with Solaris 8, perl5.00503 (or higher) is supplied with the operating system". Thanks again!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question