Solved

How to include the date in the DSGET command output file

Posted on 2009-05-12
7
449 Views
Last Modified: 2013-12-24
Hi Experts,

How could I include the date information (mmddyyy: i.e 05242009) in the output file I create with my script that already runs a DSGET to list all members in an AD group?

Thanks in advance.

0
Comment
Question by:HUSATech
[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
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24368760
Simple version if you have the date command output formatted as dd/mm/yyyy or dd.mm.yyyy. If date /t outputs in mm/dd/yyyy or mm.dd.yyyy you can switch the places of Day and Month variables. then you can use %Day%Month%Year in the dsget's output.
Hope it helps
for /F "tokens=1-4 delims=/. " %%i in ('date /t') do (
     set Day=%%i
     set Month=%%j
     set Year=%%k
  ) 

Open in new window

0
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24368815
Here is international-independent version which runs on 2003/XP and up. You can get the time as well.

FOR /F "skip=2 tokens=2-7 delims=," %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:csv') DO (
	SET Day=%%A
	SET Hour=%%B
	SET Minute=%%C
	SET Month=%%D
	SET Second=%%A
	SET Year=%%F
)

Open in new window

0
 

Author Comment

by:HUSATech
ID: 24369116
Hey thanks a lot for the quick answer, but let me ask you this: should I embed this in my batch file where I run the dsget? How should I use it?
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 4

Accepted Solution

by:
delyan_valchev earned 50 total points
ID: 24369699
Just put it in the beginning of the batch file like the example below. Based on your question, I assume you have US regional settings (mm/dd/yyyy) so I edited a bit the first version.
Hope it helps!
@echo off
for /F "tokens=1-4 delims=/. " %%i in ('date /t') do (
     set Month=%%i
     set Day=%%j
     set Year=%%k
  ) 
set FileDate=%Month%%Day%%Year%
 
dsquery user -name SomeUser | dsget user -memberof > SomeUserMembership_%FileDate%.txt

Open in new window

0
 

Author Comment

by:HUSATech
ID: 24369884
Great, worked as expected. Thanks a lot.
0
 

Author Closing Comment

by:HUSATech
ID: 31580708
Thanks again, quick and easy to implement.
0
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24380217
The "international" version has a typo. Here is the correct one:
FOR /F "skip=2 tokens=2-7 delims=," %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:csv') DO (
        SET Day=%%A
        SET Hour=%%B
        SET Minute=%%C
        SET Month=%%D
        SET Second=%%E
        SET Year=%%F
)

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

623 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