Hello friends
 
I am currently trying to write a "system boot" message onto a test wtmpx kind of file in perl in this way..
 
#####code
#!/usr/bin/perl
sub get_boottime(){
    my $k_module = "unix:::boot_time";
    my $boott = `kstat -p $k_module`;
    $boott = (split(/\t/,$boott))[1];
    $boott =~ s/^\s+//g;
    $boott =~ s/\s+$//g;
    return $boott;
    }
 

my $ut_template = 'A32 A4 A32 l s s2 x2 l2 l x20 s A257 x';
my $ut_file_write = "/u/me//pl_wtmpx";
my $ut_user      = "reboot";
my $ut_ut_id    = "";
my $ut_line    = "system boot";my $ut_pid       = "";
my $ut_type      = 2;
my $ut_exit_e_termination = "";
my $ut_exit_e_exit        = "";
my $ut_timeval            = get_boottime();
my $ut_pad                = "";
my $ut_session            = "";
my ($ut_host, $ut_syslen) = "";

my_write_boottime();


sub my_write_boottime {
     @msg_string = ($ut_user,$ut_ut_id,$ut_line,$ut_pid,$ut_type,$ut_exit_e_termination,$ut_exit_e_exit,$ut_timeval,$ut_pad,$ut_session,$ut_syslen,$ut_host);
     $boot_record = pack($ut_template, @msg_string);
     open(WTMP_H,">$ut_file_write") || die "Unable to open $ut_file_write : $! \n";
     print WTMP_H $boot_record;
     close(WTMP_H);
     }

################

 

here is the scenario:

on solaris 10 (x86):

==============

myprompt$ > perl writebootmsg.pl

myprompt$ > last -f  "/u/me//pl_wtmpx"

reboot    system boot                   Thu Oct 20 15:19 - 05:30  (14:10)

wtmp begins Thu Oct 20 15:19

************but  when I search for "system boot" message , it gives nothing*******

myprompt$ > last "system boot" -f  "/u/me//pl_wtmpx"

wtmp begins Thu Oct 20 15:19

 

On Solaris 8 (sparc) :

===================

myprompt$ > perl writebootmsg.pl

myprompt$ > last -f  "/u/me//pl_wtmpx"

reboot    system boot                   Sat Jul 23 17:50 - 05:30  (11:39)

wtmp begins Sat Jul 23 17:50

**************but again when I search for "system boot" message, it gives nothing**************

myprompt$ > last "system boot" -f ~/temp/wtmpcheck/pl_wtmpx

wtmp begins Sat Jul 23 17:50

 

can someone please suggest where is that I am going wrong in writing the record on to test wtmpx file.

 

and more small question, how can we get to know whether the wtmpx/utmpx file is corrupted ?

Thanks,

Nikhil

_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to