bash file

Status
Not open for further replies.

Adeyinka

Posts: 13   +0
Hi Gurus

I want to write a batch file in Windows 2000pro that will log all my transaction packet without having to manually put the date every other day

What I want is to click the batch file and the date will be automatiaclly update

Can somedody remind me of the syntax for date in windows that I can incoporate in to my batch file?
Or a sample copy of such?

Tank ya all:grinthumb :cool:
 
It would be helpful to know whet exactly that batch file is supposed to do.

This is the way to get the current date in an environment variable:
FOR /F "TOKENS=1,2*" %%A IN ('DATE/T') DO SET TODAY=%%B

TODAY will be the date formatted according to your locale settings.
 
Hi

Thanks for you reply. However, I tried this out and is still not working

What I want, maybe you did not get my initial question correctly .
I normally log the text file for transantion packets in a folder called "Trace" on my C: drive
The packet is initiated from a socket called "Visa" which resides in an application- based router(a Computer)
I normally set the monitoring on with the command
"nt_trace s=visa f=c:\trace\tracemonitor.txt_DATE{30_10_03}

EXplained
Initiate nt_trace from the socket (s) called visa:
file (f)should be saved in folder traces. The name of the txt file tracemonitor.txt_30_10_03(0n the 30th oct 2003)
I have added this to my bash file
"FOR /F "TOKENS=1,2*" %%A IN ('DATE/T') DO SET TODAY=%%B"
and is still not work

What I want to achieve is to automatically get the date appended to the text file whenever the bash file is activated

can somebody help out


yinka
 
Did you do something like this?

FOR /F "TOKENS=1,2*" %%A IN ('DATE/T') DO SET TODAY=%%B
nt_trace s=visa f=c:\trace\tracemonitor.txt_DATE{%TODAY}

Or was it something else. I forgot to look it up, but at work I use a batch file to name daily backups on our mailserver and it should look very much like this.
 
Hi,

The text file was not updated.
What I saw is like this
tracemonitor.txt_DATE{TODAY}
THe date was displayed AS today's date in DOS while the trace was in progress but was not appended to the tracemonitor txt file as
tracemonitor.txt_10_30_2003

Your kindest reply will be appreciated
 
How about

FOR /F "TOKENS=1,2*" %%A IN ('DATE/T') DO SET TODAY=%%B
nt_trace s=visa f=c:\trace\tracemonitor.txt_DATE{%TODAY%}
 
I still get the script not running

I think there is a way to break out system date before appending it to the text file. Note also that the text file ext does not recognise the date format without breaking it

have a look at this
DATE Example:
------------------
rem /* break out the system date for use in the filename and data line. */
for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (
set logdate=%%j%%i%%

Date /t gives the following:
MON 11/03/2003

So... Month=i, Day=j, Year=k (Since we started at position 2 we skipped 'Sun ').


Finally
set my_log=%log_date%

where my_log is a variable to be appended to the text file

I have tried this stuff but seems not to have any headway


can you have a proper look and see how this can work out

All I need to do is to get the text file doc appended with the date

period

hope somebody can help out
 
It seems tht your problem is your locale presenting dates with ambedded slashes and Windows interpreting it as a directory delimiter.
You didn't post the entire batch file you tried to use, but this works just fine for me:

:: Demonstrate datestamping
for /f "tokens=2,3,4 delims=. " %%a in ('date /t') do set mydate=%%a_%%b_%%c
mkdir myPrefix%mydate%mySuffix
 
locale setting is mm-dd-yy

whenever I type "date" at DOs, what I got is Tue 11/04/2003

That is my locale setting
and again I don't understand where mkdir myprefix%mydate%mysuffix fit in into in what i want to acheive. could you please explain a bit

Kindest of you!
 
I just put mkdir because it was an easy command for me to test this on. You would replace it with nt_trace s=visa f=c:\trace\tracemonitor.txt_%mydate%
 
Status
Not open for further replies.
Back