[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

trouble shoot my counter date code...

Posted on 1998-01-13
1
Medium Priority
?
954 Views
Last Modified: 2013-12-25
This is from a script I got which was made for UNIX, but I'm running on my NT 4.0 with perl 5 installed.

# This section is the main log

$PRINT = "Content-type:\ text/plain\n\n ";
$shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
       {
         $PRINT;
      
      open (MAINLOG, ">>$mainlog");
      print MAINLOG "Time: $shortdate\n";
      print MAINLOG "User: $ENV{'REMOTE_USER'}\n";
      print MAINLOG "Host: $ENV{'REMOTE_HOST'}\n";
      print MAINLOG "Addr: $ENV{'REMOTE_ADDR'}\n";
      print MAINLOG "With: $ENV{'HTTP_USER_AGENT'}\n";
      print MAINLOG "Page: $ENV{'HTTP_FROM'}\n";
      print MAINLOG "From: $ENV{'HTTP_REFERER'}\n\n";
      close (MAINLOG);
}

The main.log file indicates that it is having trouble getting the date, as seen excerpted below:

Time: The system cannot accept the date entered.
Enter the new date: (mm-dd-yy) The system cannot accept the date entered.
Enter the new date: (mm-dd-yy) The system cannot accept the date entered.
Enter the new date: (mm-dd-yy)
User:
Host:
Addr:
With:
Page:
From:

What do i do to modify this so it can run on my NT machine?
0
Comment
Question by:retroman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
paul_t earned 40 total points
ID: 1831824
'date' command for NT performs different way than for UNIX,
so you shall replace:

$shortdate = `date +"%D %T %Z"`;

with:

$shortdate = `date /T`;

or (preferable)

$shortdate = localtime;

or you may display any part of time you'l want if
splitting localtime to parts with the help of:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                            localtime;

0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

656 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