bash file

By Adeyinka ยท 9 replies
Oct 27, 2003
  1. 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:
  2. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    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.
  3. Adeyinka

    Adeyinka TS Rookie Topic Starter Posts: 16


    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}

    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

  4. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    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.
  5. Adeyinka

    Adeyinka TS Rookie Topic Starter Posts: 16


    The text file was not updated.
    What I saw is like this
    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

    Your kindest reply will be appreciated
  6. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    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%}
  7. Adeyinka

    Adeyinka TS Rookie Topic Starter Posts: 16

    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 ').

    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


    hope somebody can help out
  8. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    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
  9. Adeyinka

    Adeyinka TS Rookie Topic Starter Posts: 16

    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!
  10. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    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%
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...