Computing.Net > Forums > Disk Operating System > logfile info

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

logfile info

Reply to Message Icon

Original Message
Name: Miskva
Date: February 25, 2003 at 13:39:13 Pacific
Subject: logfile info
OS: w98
CPU/Ram: 456
Comment:

I would like to get a logfile, with on the same line:
- some text
- the output of "date /t"
- the output of "time /t"

So, the output should look like this
"Started action at : 'date /t' 'time /t'"

Where 'date /t' is the current date, and ' time /t' is the current time

At the moment, I have got this
echo Started action at : >> logfile.log
date /t >> logfile.log
time /t >> logfile.log

Which of course, creates 3 lines every time. It must be used for Win2000 !



Report Offensive Message For Removal


Response Number 1
Name: Miskva
Date: February 25, 2003 at 14:03:11 Pacific
Reply: (edit)

Doom, I've seen the answer in thread "How to create a log file in 1 line"

it works all right, thanks man


Report Offensive Follow Up For Removal

Response Number 2
Name: Secret_Doom
Date: February 25, 2003 at 17:35:35 Pacific
Reply: (edit)

Ok! BTW, I've used the variables %DATE% and %TIME% on the scripts from that thread. Though they are pre-set on Win2000, they can be manually unset before running the script, making it fail. Besides, WinNT don't have those variables pre-set, only Win2K and XP do. So, it's better to use DATE/T and TIME/T, like this:

for /F "tokens=*" %%A in ('date/T') do set LOG=%%A
for /F "tokens=*" %%A in ('time/T') do set LOG=%LOG% %%A
echo Started action at: %LOG%>> logfile.log
set LOG=

There's a work around the %time% variable issue, but it's easier to use this method based on time/T. I've only used the variables on that script because the original poster stated his OS as Windows 2000 and he needed the seconds on the time, which is not included in TIME/T's output.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

___________________________________________________________


Report Offensive Follow Up For Removal

Response Number 3
Name: Miskva
Date: February 26, 2003 at 11:40:33 Pacific
Reply: (edit)

But mine was meant for 2000 all right, but I'll keep it in mind when my script should run on NT as well.

BTW, which method is advised, whenever you want to check the environment ? Which variable to check (apparently none for W9X)


Report Offensive Follow Up For Removal

Response Number 4
Name: Secret_Doom
Date: February 26, 2003 at 12:48:21 Pacific
Reply: (edit)

What do you mean by "check the environment"?

If you mean check the environment's size, I don't know of any variable holding that value on any Windows nor DOS version.

In fact, since there's no switch on CMD.EXE (NT systems' command interpreter) to specify the size of the environment space, I think it's huge (just not to say unlimited).

-- Leonnardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal

Response Number 5
Name: Miskva
Date: March 1, 2003 at 03:06:17 Pacific
Reply: (edit)

OK, I wanted this question to you anyway, Doom .. I am looking for some code to check the version of windows while running (calling it the environment)

I know there is not one variable which states this, but I know there are some system variables which are typically set on some, and unused on others ..


Report Offensive Follow Up For Removal


Response Number 6
Name: Secret_Doom
Date: March 1, 2003 at 10:08:34 Pacific
Reply: (edit)

Oooh, now I get it.

The only variable which holds information that can be used to identify the OS is the %OS% variable. That variable is set by default on all NT systems to "Windows_NT" (no quotes). It can be used to differ NT systems from Win9x/DOS.

However, if you need to determine the environment more exately, the way to go is to use the VER cmd, with the FIND cmd. Here goes the outputs:

Microsoft Windows 95 [...]
Microsoft Windows 98 [...]
Microsoft Windows 2000 [...]
Microsoft Windows XP [...]
Microsoft Windows NT [...]
MS-DOS 6.22

I'm not sure about the last two outputs, but I think they're right.

Those outputs will get you the exact environment, except for the Windows 9x, because when you get such output, you might be inside Windows or not. To determine if Windows is running, in that case, you can look for the switch /R on the XCOPY cmd help screen, which will only be present if Windows is running:

XCOPY/? |FIND "/R" > nul
if not errorlevel=1 goto Win

I think that happens because XCOPY runs in 16bit mode on DOS and 32bit mode on Windows.

I would classify the Microsoft OS's, by similarity, like this:

1. Win9x / DOS
  a. Windows 95 / Windows 98
  b. DOS

2. NT systems
  a. Windows NT
  b. Windows 2000 / Windows XP

And I'm not quite sure if Windows ME would be on the 1a block or in a block of itself, under the block 1 (like 1c).

I hope my analogy were understandable...

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal

Response Number 7
Name: Secret_Doom
Date: March 4, 2003 at 22:59:25 Pacific
Reply: (edit)

By the way, that OS analogy regards only aspects that involve batch scripting, of course. And it is my personal oppinion.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


Report Offensive Follow Up For Removal






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software