Solved

Need to display YEAR data from Solaris wtmpx file contents

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CPU monthly average? 12 139
How to Change Interface on Cisco IOU 11 121
dot directory in FreeBSD??? 4 92
replace column/record content in a *csv file based on a regular expression 6 80
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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.

726 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