Hi Monks,

This is my first pray for you guys, as I'm a Perl beginner. First of all, thank you for all the useful advices that I found in this website.

We are currently using a home-made monitoring for our Windows Servers, using VBScript. I am trying to convert it into Perl, and so far it's working.

But I'm facing a little problem : our system is using the Excel timestamp.

The output is something like "41792,4854976852", where 41792 is the number of days since the epoch, and the other part is the time.

When I use the "time" function in perl, I get something like "1401797571". I need to get the Excel timestamp format as an output.

As if it wasn't complicated enough, we can't add any module to perl.

I don't know if it will be useful considering my issue, but here's my code (it's not finished yet and it only works with AIX OS, so don't worry if it doesn't work for you) :

use strict; use warnings; use Cwd qw(); use 5.010; use Net::SMTP; use MIME::Lite; my $path = Cwd::cwd(); # Recovering General.ini parameters my $filename = "$path/General.ini"; chomp $filename; my $fh; my $val; my $parameter; my $Customer; my $Server; my $expediteur; my $destinataire; my $SMTP; my $svmonouput; my $alerte = 0; open($fh,'<',$filename) or die "Can't open the file $filename as read- +only."; my @generalsparameter=<$fh>; foreach my $line (@generalsparameter) { my @values = split(/=/,$line); $parameter = $values[0]; $val = $values[1]; if ($parameter eq "Customer") { $Customer = $val; chomp($Customer); } elsif ($parameter eq "Server_name") { $Server = $val; chomp($Server); } elsif ($parameter eq "From_email") { $expediteur = $val; chomp($expediteur); } elsif ($parameter eq "Dest_email") { $destinataire = $val; chomp($destinataire); } elsif ($parameter eq "SMTP") { $SMTP = $val; chomp($SMTP); } } close($fh); # Using "svmon -P" to get RAM usage for a process $svmonouput = `svmon -P | grep $ARGV[2]`; my @ParsingOutput = split(/ {1,}/,$svmonouput); my $result = $ParsingOutput[2] * 4 / 1024; # Showing the result (will write this line into a file, later) print "$Customer;$Server;$ARGV[2];Memory;" . time . ";$ARGV[1];$result +";

As you can see, I use "time" in the final "print".

Is there any way to convert it into Excel timestamp (or to use anything else to get Excel timestamp format) ?

Thank you in advance !

Edit : I almost forgot to tell you : I am using Perl v5.8.8 built for aix-thread-multi.

Varkh


In reply to Using Excel timestamp with perl by Varkh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.