Solved

trouble shoot my counter date code...

Posted on 1998-01-13
1
944 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
1 Comment
 
LVL 2

Accepted Solution

by:
paul_t earned 20 total points
Comment Utility
'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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now