Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Apache Request timestamp

Posted on 2006-05-13
5
Medium Priority
?
365 Views
Last Modified: 2011-09-20
Hi,
I have a perl script to be executed via web. I just to determine, at what *timestamp* the Apache has received the request.
I want to catch this value in the perl script, preferably through environment variable i.e. $ENV{'REQUEST_TIMESTAMP'}.
Thanks,
Anil
0
Comment
Question by:bsdex
3 Comments
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 1000 total points
ID: 16679671
Hi,

Try this example:

   use Time::HiRes qw(time);

   # Inside request script
   $request_timestamp = time;

   # Inside response script
   $responce_timestamp = time;
   $elapsed_seconds = $request_timestamp - $responce_timestamp;

If you're not worried about sub-second accuracy, you can forget about Time::HiRes.

R.K
0
 
LVL 1

Author Comment

by:bsdex
ID: 16679965
Hmmm... I am not sure about the request/response script. I have a single script.
#!/usr/bin/perl
use strict;
use Data::Dumper;
print "Content-type: text/plain \n\n";
print  Dumper(\%ENV);

Please suggest me where to insert those codes.
Thanks.
0
 
LVL 15

Assisted Solution

by:periwinkle
periwinkle earned 1000 total points
ID: 16870592
Use:


#!/usr/bin/perl
use strict;
use Data::Dumper;
use Time::HiRes qw(time);

$request_timestamp = time;

print "Content-type: text/plain \n\n";
print "Timestamp: $request_timestamp\n";
print  Dumper(\%ENV);

If you require the timestamp to be human readable, use:

#!/usr/bin/perl
use strict;
use Data::Dumper;
use Time::HiRes qw(time);

$request_timestamp = GetDateTime();

print "Content-type: text/plain \n\n";
print "Timestamp: $request_timestamp\n";
print  Dumper(\%ENV);

sub GetDateTime {
      @Month=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
      $now=time;
      ($sec,$min,$hour,$mday,$mon,$year)=localtime($now);
      $thisdatetime=sprintf("%02d/%2d/%04d %02d\:%02d\:%02d",$mon+1, $mday,$year+1900, $hour, $min, $sec);

      return $thisdatetime;
}


0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

580 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