Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to display YEAR data from Solaris wtmpx file contents

Posted on 2007-03-21
4
Medium Priority
?
854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses

636 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