Varkh has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Excel timestamp with perl
by Corion (Patriarch) on Jun 03, 2014 at 12:27 UTC | |
by Varkh (Initiate) on Jun 03, 2014 at 12:36 UTC | |
by dasgar (Priest) on Jun 03, 2014 at 22:47 UTC | |
by Varkh (Initiate) on Jun 04, 2014 at 13:14 UTC | |
by soonix (Chancellor) on Jun 03, 2014 at 13:09 UTC | |
by Varkh (Initiate) on Jun 03, 2014 at 13:35 UTC | |
by crusty_collins (Friar) on Jun 03, 2014 at 20:42 UTC | |
by Anonymous Monk on Jun 16, 2014 at 23:09 UTC | |
|
Re: Using Excel timestamp with perl
by Varkh (Initiate) on Jun 03, 2014 at 15:09 UTC |