Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time stamp in Perl

Status
Not open for further replies.

gps1979

IS-IT--Management
Joined
Nov 5, 2007
Messages
3
Location
CA
Hi Guys,

I have a following script where I am redirecting my script's output to a log file with date/time stamp:

@echo on

FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET mydate=%%c-%%a-%%b
FOR /f "tokens=1-2 delims=: " %%a in ('TIME/T') do SET mytime=%%a-%%b

perl ControlScan.pl > controlscan%mydate%-%mytime%.log

Upon execution, it shows the following error:

time: /t: Not Executable: The system can not find the file specified

Date: Bad Date conversion : /t
Usage: Date [-cu] [+format]
Date [-cut] <date-time>

Does anyone know the solution? Thanks in advance. I really appreciate the response.

Thanks again
GPS

 
Are you on windows or unix? Why not just do it all in the perl script?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
HI Travs69, thanks for responding. I am on Windows and running this in a Batch file (*.bat). Any idea how to do it in a perl script?

Thanks again.
 
Are those single ticks or back ticks around time /t? If you can edit the ControlScan.pl you can just add your logging into that script. Look up localtime in perl.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks Travis, I think I can better check it within the Perl script. A good suggestion indeed. Thanks man!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top