Solved

Need to display YEAR data from Solaris wtmpx file contents

Posted on 2007-03-21
4
843 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now