Veritas-bu

[Veritas-bu] Convert ctime to english...

2004-01-19 11:47:05
Subject: [Veritas-bu] Convert ctime to english...
From: hampus.lind AT rps.police DOT se (Hampus Lind)
Date: Mon, 19 Jan 2004 17:47:05 +0100
This is a multi-part message in MIME format.

------=_NextPart_000_00D2_01C3DEB4.4123CA50
Content-Type: multipart/alternative;
        boundary="----=_NextPart_001_00D3_01C3DEB4.4123CA50"


------=_NextPart_001_00D3_01C3DEB4.4123CA50
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thank you all, i found some scripts that i can use. I have attached them =
if anyone else is interested.
All kredit to the author (look in the files)..

Keep the files in the same dir, chmod 744.
I have modified the perl script a litel bit so it will fit in to my =
requests.

This is my test, it is the "CALCULTED TIMESTAMP" that i want:

# echo "Thu Dec 18 17:05:31 2003" | perl date_to_timestamp.pl

date commands output:
~~~~~~~~~~~~~~~~~~~~~
                Thu Dec 18 17:05:31 2003

arguments to the mktime() method:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sec =3D 31, min =3D 05, hour =3D 17,
date =3D 18, month =3D 11, year (this yr. - 1900) =3D 103, day =3D 4

********************************
CALCULATED TIMESTAMP =3D 1071763531
********************************
PRESENT TIMESTAMP    =3D 1074530969
********************************


Best Regards=20
Hampus Lind



  ----- Original Message -----=20
  From: Ellwood, MW (Mike)=20
  To: 'Hampus Lind'=20
  Sent: Monday, January 19, 2004 5:21 PM
  Subject: RE: [Veritas-bu] Convert ctime to english...


  Hampus,=20

  I'm not clear which way round you want the conversion, but if it's =
from
  "seconds past the epoch" to a more readable format, then I recently =
wrote something
  like this to be able to convert the "non -U" versions of bperror to =
have a more-readable date, but
  still have only one line per record (for grepping, etc). It's in Perl, =
which I'm just experimenting with
  (not an expert). But basically, the trick to it is all in the =
"localtime" function of Perl (which seems
  to be based on a similar function in Perl). If you want to convert the =
other way, I haven't done that
  yet, but it shouldn't be too difficult. Anyway, you are welcome to =
look at this and pick up any ideas
  (and probably improve on them):

  #!/usr/bin/perl -w

  # Name:         identify_bperror
  # Purpose:      To convert the "time" format datestamp on non -U =
bperror output to "localtime"
  #               i.e. make it readable.
  #               The need for this is that -U (and similar) output is =
split over several output
  #               lines for each real message. When parsing by script, =
this needs to be on a si
  ngle
  #               line. This allows the script to produce readable times =
without doing its own time
  #               processing.
  # Usage:        As a filter, i.e. bperror <parameters>  | =
identify_bpread | some_other-script
  # Arguments:    1 (or more) =3D turn on debug printing
  # History:
  # 2004.01.12    Initial Version:        12 Jan 2004                    =
         # 2004.01.12

  #use warnings;
  use strict;

  my $mytime1;
  my @month_names=3Dqw(Jan Feb Mar Apr May Jun Jul Sep Oct Nov Dec);
  my $mm;         # month number =3D $mon+1
  my $month;      # month name
  my @day_names=3Dqw(Sun Mon Tue Wed Thu Fri Sat);
  my $date_string;
  my $client;
  my $timestamp;
  my $debug;
  my $line;
  my $rest_of_line;

  if ( $#ARGV >=3D 0 ) {
  $debug =3D $ARGV[0];      # 1 =3D TRUE
  }

  # See perldoc -f localtime and perldoc -f time

  #  0    1    2     3     4    5     6     7     8
  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =3D =
localtime(time);
  $year +=3D 1900;
  #print ("$sec $min $hour $mday $mon $year $wday $yday $isdst\n");
  $mm =3D $mon+1;           # month number =3D $mon+1
  $month =3D $month_names[$mon];    # month name
  my $day=3D $day_names[$wday];

  #printf ("%04d.%02d.%02d %02d:%02d:%02d %s\n", $year, $mm, $mday, =
$hour, $min, $sec, $day);
  #$date_string=3Dsprintf ("%04d.%02d.%02d %02d:%02d:%02d %s\n", $year, =
$mm, $mday, $hour, $min,
  $sec, $day);

  #print "$date_string\n";

  $debug and print "Number of arguments =3D $#ARGV \n";


  while ( defined ($line=3D<STDIN>) ) {


      if ( $line =3D~ m{
                          (^                      # capture to $1, start =
of line
                           \d\d\d\d\d\d\d\d\d\d   # 10 digits
                          )\b                     # end of capture, word =
boundary
                          (                       # capture to $2
                           .*$                    # rest of line
                          )                       # end of capture

                     }x ) {                       # comments/ws allowed =
in regex

          $timestamp =3D $1;                        # 1st captured =
string
          $rest_of_line =3D $2;                     # 2nd captured =
string


          ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =3D =
localtime($timestamp);
          $year +=3D 1900;                          # unepochify year
          $mm =3D $mon+1;                           # convert month from =
index to normal month no

          $day=3D $day_names[$wday];                # get alpha weekday =
from day-number
          $date_string=3Dsprintf ("%04d.%02d.%02d %02d:%02d:%02d %s", =
$year, $mm, $mday, $hour, $
  min,
          $sec, $day);

          $line =3D~ s{
                      (^                      # capture to $1, start of =
line
                       \d\d\d\d\d\d\d\d\d\d   # 10 digits
                      )\b                     # end of capture, word =
boundary
                      (                       # capture to $2
                       .*$                    # rest of line
                      )                       # end of capture
                    }                     # end of select
  #                                       # start of replace
                    {$date_string$rest_of_line}x # concatenate operator =
didn't work here ##
  #                                              # also beware =
superfluous stuff before }
                     ;                    # comments, WS allowed ("-x" =
flag)
  #                                       # end of replace
      }   # end of if block



  print $line;
  }   # end of while block



  exit 0;
    -----Original Message-----
    From: veritas-bu-admin AT mailman.eng.auburn DOT edu =
[mailto:veritas-bu-admin AT mailman.eng.auburn DOT edu]On Behalf Of Hampus Lind
    Sent: 19 January 2004 15:47
    To: veritas-bu AT mailman.eng.auburn DOT edu
    Subject: [Veritas-bu] Convert ctime to english...


    Hi!

    Does anyone have a unix script to convert a "real" date vaule to =
ctime??=20
    If so i would be very pleased if a could get a copy....

    Thanks!

    Best Regards
    Hampus Lind

------=_NextPart_001_00D3_01C3DEB4.4123CA50
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thank you all, i found some scripts =
that i can use.=20
I have attached them if anyone else is interested.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>All kredit to the author (look in the=20
files)..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Keep the files in the same dir, chmod=20
744.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have modified the perl script a litel =
bit so it=20
will fit in to my requests.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is my test, it is the "CALCULTED =
TIMESTAMP"=20
that i want:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2># echo "Thu Dec 18 17:05:31 2003" | =
perl=20
date_to_timestamp.pl</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>date commands=20
output:<BR>~~~~~~~~~~~~~~~~~~~~~<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Thu Dec 18 17:05:31 2003</DIV>
<DIV>&nbsp;</DIV>
<DIV>arguments to the mktime()=20
method:<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</DIV>
<DIV>&nbsp;</DIV>
<DIV>sec =3D 31, min =3D 05, hour =3D 17,<BR>date =3D 18, month =3D 11, =
year (this yr. -=20
1900) =3D 103, day =3D 4</DIV>
<DIV>&nbsp;</DIV>
<DIV>********************************<BR>CALCULATED TIMESTAMP =3D=20
1071763531<BR>********************************<BR>PRESENT=20
TIMESTAMP&nbsp;&nbsp;&nbsp; =3D=20
1074530969<BR>********************************<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Best Regards </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hampus Lind</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3DM.W.Ellwood AT rl.ac DOT uk =
href=3D"mailto:M.W.Ellwood AT rl.ac DOT uk">Ellwood, MW=20
  (Mike) </A></DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dhampus.lind AT rps.police DOT se=20
  href=3D"mailto:hampus.lind AT rps.police DOT se">'Hampus Lind'</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, January 19, 2004 =
5:21=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: [Veritas-bu] =
Convert ctime=20
  to english...</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>Hampus, </SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>I'm=20
  not clear which way round you want the conversion, but if it's=20
  from</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>"seconds past the epoch" to a more readable =
format,=20
  then I recently wrote something</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>like=20
  this to be able to convert the "non -U" versions of bperror to have a=20
  more-readable date, but</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>still have only one line per record (for =
grepping,=20
  etc). It's in Perl, which I'm just experimenting =
with</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>(not=20
  an expert). But basically, the trick to it is all in the "localtime" =
function=20
  of Perl (which seems</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>to=20
  be based on a similar function in Perl). If you want to convert the =
other way,=20
  I haven't done that</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>yet,=20
  but it shouldn't be too difficult. Anyway, you are welcome to look at =
this and=20
  pick up any ideas</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>(and=20
  probably improve on them):</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>#!/usr/bin/perl -w</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>#=20
  Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
identify_bperror<BR>#=20
  Purpose:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To convert the "time" format =
datestamp=20
  on non -U bperror output to=20
  =
"localtime"<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  i.e. make it=20
  =
readable.<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
  The need for this is that -U (and similar) output is split over =
several=20
  =
output<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
  lines for each real message. When parsing by script, this needs to be =
on a=20
  =
si<BR>ngle<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
  line. This allows the script to produce readable times without doing =
its own=20
  =
time<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
  processing.<BR># Usage:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As a =
filter,=20
  i.e. bperror &lt;parameters&gt;&nbsp; | identify_bpread |=20
  some_other-script<BR># Arguments:&nbsp;&nbsp;&nbsp; 1 (or more) =3D =
turn on=20
  debug printing<BR># History:<BR># 2004.01.12&nbsp;&nbsp;&nbsp; Initial =

  Version:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12 Jan=20
  =
2004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # 2004.01.12</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>#use=20
  warnings;<BR>use strict;</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>my=20
  $mytime1;<BR>my @month_names=3Dqw(Jan Feb Mar Apr May Jun Jul Sep Oct =
Nov=20
  Dec);<BR>my $mm;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # =
month=20
  number =3D $mon+1<BR>my $month;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # month =
name<BR>my=20
  @day_names=3Dqw(Sun Mon Tue Wed Thu Fri Sat);<BR>my =
$date_string;<BR>my=20
  $client;<BR>my $timestamp;<BR>my $debug;<BR>my $line;<BR>my=20
  $rest_of_line;</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>if (=20
  $#ARGV &gt;=3D 0 ) {<BR>$debug =3D =
$ARGV[0];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # 1 =3D=20
  TRUE<BR>}</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D881450816-19012004>#=20
  See perldoc -f localtime and perldoc -f time</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>#&nbsp; 0&nbsp;&nbsp;&nbsp; =
1&nbsp;&nbsp;&nbsp;=20
  2&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; =
4&nbsp;&nbsp;&nbsp;=20
  5&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp; =
7&nbsp;&nbsp;&nbsp;&nbsp;=20
  8<BR>my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =3D=20
  localtime(time);<BR>$year +=3D 1900;<BR>#print ("$sec $min $hour $mday =
$mon=20
  $year $wday $yday $isdst\n");<BR>$mm =3D=20
  $mon+1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # =
month=20
  number =3D $mon+1<BR>$month =3D $month_names[$mon];&nbsp;&nbsp;&nbsp; =
# month=20
  name<BR>my $day=3D $day_names[$wday];</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>#printf ("%04d.%02d.%02d %02d:%02d:%02d =
%s\n", $year,=20
  $mm, $mday, $hour, $min, $sec, $day);<BR>#$date_string=3Dsprintf=20
  ("%04d.%02d.%02d %02d:%02d:%02d %s\n", $year, $mm, $mday, $hour,=20
  $min,<BR>$sec, $day);</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>#print =
"$date_string\n";</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
  class=3D881450816-19012004>$debug and print "Number of arguments =3D =
$#ARGV=20
  \n";</SPAN></FONT></DIV>
  <DIV><FONT face=3DArial color=3D#0000ff =
size=3D2></FONT>&nbsp;</DIV><FONT face=3DArial=20
  color=3D#0000ff size=3D2><SPAN class=3D881450816-19012004>
  <DIV><BR>while ( defined ($line=3D&lt;STDIN&gt;) ) {</DIV>
  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allowed in regex</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $timestamp =3D=20
  =
$1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # 1st captured string<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  $rest_of_line =3D=20
  =
$2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # 2nd captured string</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =3D=20
  localtime($timestamp);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$year +=3D=20
  =
1900;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
  # unepochify year<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $mm =
=3D=20
  =
$mon+1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
  # convert month from index to normal month no</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $day=3D=20
  =
$day_names[$wday];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # get alpha weekday from=20
  day-number<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$date_string=3Dsprintf=20
  ("%04d.%02d.%02d %02d:%02d:%02d %s", $year, $mm, $mday, $hour,=20
  $<BR>min,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sec, =
$day);</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $line =3D~=20
  =
s{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  =
(^&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # capture to $1, start of=20
  =
line<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  \d\d\d\d\d\d\d\d\d\d&nbsp;&nbsp; # 10=20
  =
digits<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  =
}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # end of=20
  =
select<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
  # start of=20
  =
replace<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  {$date_string$rest_of_line}x # concatenate operator didn't work here=20
  =
##<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # also beware superfluous stuff before=20
  =
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  =
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  # comments, WS allowed ("-x"=20
  =
flag)<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
  # end of replace<BR>&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; # end of if =
block</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>print $line;<BR>}&nbsp;&nbsp; # end of while block</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>exit 0;</SPAN></FONT></DIV>
  <BLOCKQUOTE dir=3Dltr=20
  style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
    <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
    size=3D2>-----Original Message-----<BR><B>From:</B>=20
    veritas-bu-admin AT mailman.eng.auburn DOT edu=20
    [mailto:veritas-bu-admin AT mailman.eng.auburn DOT edu]<B>On Behalf Of =
</B>Hampus=20
    Lind<BR><B>Sent:</B> 19 January 2004 15:47<BR><B>To:</B>=20
    veritas-bu AT mailman.eng.auburn DOT edu<BR><B>Subject:</B> [Veritas-bu] =
Convert=20
    ctime to english...<BR><BR></FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>Hi!</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Does anyone have a unix script to =
convert a=20
    "real" date&nbsp;vaule to&nbsp;ctime?? </FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>If so i would be very&nbsp;pleased =
if a could=20
    get a copy....</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>Best Regards</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>Hampus Lind</FONT></DIV>
    <DIV><FONT face=3DArial=20
size=3D2></FONT>&nbsp;</DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_001_00D3_01C3DEB4.4123CA50--

------=_NextPart_000_00D2_01C3DEB4.4123CA50
Content-Type: application/octet-stream;
        name="run.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
        filename="run.sh"

#!/bin/sh

#
# @ nabarun of www.arzoo.com
#

#
# clear the screen
#
clear;


#
# run the unix command date and pass its input to the output of 
# the perl script  DateToTimeStamp.pl.
#
date | perl date_to_timestamp.pl;


------=_NextPart_000_00D2_01C3DEB4.4123CA50
Content-Type: application/octet-stream;
        name="date_to_timestamp.pl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="date_to_timestamp.pl"

#!/usr/bin/perl

#
# author:  nabarun of www.arzoo.com
#

use POSIX;

my (
    $wday,
    $year,
    $month,
    $date,
    $time,
    @wdays,
    @months,
);

#
# Days in a week, as appears in the output of unix shell command "date"
#
@wdays =3D ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

#
# Months in a year, as appears in the output of unix shell command =
"date"
#
@months =3D ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", =
"Sep", "Oct", "Nov", "Dec");


#
# the date commands output is passed as the input here (by the =
RunScript.sh)
#
$inputDate =3D <STDIN>;

#
# storing the different words in the output
#
@words =3D split (/\s+/, $inputDate);


$wday  =3D $words[0];
$month =3D $words[1];
$date  =3D $words[2];
$time  =3D $words[3];
$year  =3D $words[4];

print "\ndate commands output:\n"
      . "~~~~~~~~~~~~~~~~~~~~~\n\t\t$inputDate\n";


for($i =3D 0; $i <=3D $#wdays; $i++) {
  if ("$wday" eq "$wdays[$i]") {
    $wday =3D $i;
#   print "$wday =3D $wdays[$i]\n";
    last;
  }
}

for($i =3D 0; $i <=3D $#months; $i++) {
  if ("$month" eq "$months[$i]") {
    $month =3D $i;
#   print "$month =3D $months[$i]\n";
    last;
  }
}

@time_components =3D split (/\:/, $time);
$hour  =3D $time_components[0];
$min  =3D $time_components[1];
$sec  =3D $time_components[2];
$year =3D $year - 1900;

print "arguments to the mktime() method:\n"
  .   "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
print "sec =3D $sec, min =3D $min, hour =3D $hour,\ndate =3D $date, =
month =3D $month, "
  . "year (this yr. - 1900) =3D $year, day =3D $wday \n\n";


$timestamp =3D mktime($sec, $min, $hour, $date, $month, $year, $wday, 0, =
-1);

print "********************************\n";
print "CALCULATED TIMESTAMP =3D ";
print "$timestamp \n";
print "********************************\n";

print "PRESENT TIMESTAMP    =3D ";
print (time());
print "\n";
print "********************************\n\n";


------=_NextPart_000_00D2_01C3DEB4.4123CA50--