Discussion Locked

Unix to NT command translations

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I?m looking for a simple solution to a simple question.
Recently, I wanted to have a log of every time I received a status change event for a SNMP Manager I'm using.
The solution for both NT and Unix was identical:

echo ?nodename TIME/DATE event_message? >> /log/err_log

Every time an event was received, the Event Message text was added as a new line in the /log/err_log.

This worked great, until my criteria changed. Now I want a new log for everyday, so that I can generate daily reports. The Unix solution was simple:

echo ?nodename TIME/DATE event_message? >> /log/err_log`date +%m%d%y`

Now, each day events create an error log file that includes a datestamp as part of the name, (i.e. /log/err_log030701).

The problem is that there seems to be no equivalent command in the NT command line. Anyone have a clue on how to accomplish in NT what is so easy in Unix?

1 reply

by andy_mellor

This works on NT 4. Here's how to set three variables to get your day/month/year. Use these variables to create your filename.
NB no line breaks in middle of each command.

FOR /F "tokens=2 delims=/ " %%i IN ('date /t') DO set day=%%i

FOR /F"tokens=3 delims=/ " %%i IN ('date /t') DO set mth=%%i

FOR /F "tokens=4 delims=/ " %%i IN ('date /t') DO set yer=%%i

Hope this gets you on your way!

This discussion is closed to new replies.