Solved

trouble shoot my counter date code...

Posted on 1998-01-13
1
948 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 20 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

740 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