batch commands work in Win XP but not 98

  • Thread starter Thread starter eganders
  • Start date Start date
E

eganders

Guest
Why do the following commands result in garbage stored in tractest.txt
for Windows 98, but puts the date and time headings into the file
"tracetest.txt" for Windows XP as I want? Can these statements be
changed in some way so that the date and time are stored in the file
properly?

date >> tracetest.txt < nul
time >> tracetest.txt < nul

I have a batch file that puts the date and time in the header of a
section of a file prior to running a test. I need to identify the
date and time that the test is run. Each time the test is run, the
date and time are placed in the file and the test and the results are
stored in the file appended to the results of the last test run. This
works just fine for Windows XP, but creates a long file filled with
garbage characters when either of these statements are run for Windows
98.

microsoft.public.win98.gen_discussion
 
Re: batch commands work in Win XP but not 98

eganders wrote:
| Why do the following commands result in garbage stored in tractest.txt
| for Windows 98, but puts the date and time headings into the file
| "tracetest.txt" for Windows XP as I want? Can these statements be
| changed in some way so that the date and time are stored in the file
| properly?
|
| date >> tracetest.txt < nul
| time >> tracetest.txt < nul

Instead of nul, try to input the ENTER key-- but I don't know how to do
it! (Nul, for me, created a monstrosity of a file! No one else should
ever try it!)

Alternatively, look for something here...
http://home7.inet.tele.dk/batfiles/batfiles.htm

But I haven't been able to find it, myself, after 1/2 hour's study!

| I have a batch file that puts the date and time in the header of a
| section of a file prior to running a test. I need to identify the
| date and time that the test is run. Each time the test is run, the
| date and time are placed in the file and the test and the results are
| stored in the file appended to the results of the last test run. This
| works just fine for Windows XP, but creates a long file filled with
| garbage characters when either of these statements are run for Windows
| 98.
|
| microsoft.public.win98.gen_discussion

--
Thanks or Good Luck,
There may be humor in this post, and,
Naturally, you will not sue,
Should things get worse after this,
PCR
pcrrcp@netzero.net
 
Re: batch commands work in Win XP but not 98

eganders wrote:
> Why do the following commands result in garbage stored in tractest.txt
> for Windows 98, but puts the date and time headings into the file
> "tracetest.txt" for Windows XP as I want? Can these statements be
> changed in some way so that the date and time are stored in the file
> properly?
>
> date >> tracetest.txt < nul
> time >> tracetest.txt < nul
>
> I have a batch file that puts the date and time in the header of a
> section of a file prior to running a test. I need to identify the
> date and time that the test is run. Each time the test is run, the
> date and time are placed in the file and the test and the results are
> stored in the file appended to the results of the last test run. This
> works just fine for Windows XP, but creates a long file filled with
> garbage characters when either of these statements are run for Windows
> 98.
>
> microsoft.public.win98.gen_discussion



eganders:

You might try asking in:

alt.msdos.batch


HTH & GL

John


--
\\\||///
------------------o000----(o)(o)----000o----------------
----------------------------()--------------------------
'' Madness takes its toll - Please have exact change. ''

John Dulak - Gnomeway Services - http://tinyurl.com/2qs6o6
 
Re: batch commands work in Win XP but not 98

Re: batch commands work in Win XP but not 98

On Mar 3, 7:52 pm, "PCR" <pcr...@netzero.net> wrote:
> eganders wrote:
>
> | Why do the following commands result in garbage stored in tractest.txt
> | for Windows 98, but puts the date and time headings into the file
> | "tracetest.txt" for Windows XP as I want?  Can these statements be
> | changed in some way so that the date and time are stored in the file
> | properly?
> |
> | date >> tracetest.txt < nul
> | time >> tracetest.txt < nul
>
> Instead of nul, try to input the ENTER key-- but I don't know how to do
> it! (Nul, for me, created a monstrosity of a file! No one else should
> ever try it!)
>
> Alternatively, look for something here...http://home7.inet.tele.dk/batfiles/batfiles.htm
>
> But I haven't been able to find it, myself, after 1/2 hour's study!
>
> | I have a batch file that puts the date and time in the header of a
> | section of a file prior to running a test.  I need to identify the
> | date and time that the test is run.  Each time the test is run, the
> | date and time are placed in the file and the test and the results are
> | stored in the file appended to the results of the last test run.  This
> | works just fine for Windows XP, but creates a long file filled with
> | garbage characters when either of these statements are run for Windows
> | 98.
> |
> | microsoft.public.win98.gen_discussion
>
> --
> Thanks or Good Luck,
> There may be humor in this post, and,
> Naturally, you will not sue,
> Should things get worse after this,
> PCR
> pcr...@netzero.net


Someone suggested

echo %date% >> tracetest.txt
echo %time% >> tracetest.txt

for Windows XP and it created a much better header of just the date
and time instead of a bunch of garbage around it.

However, does it work with Windows 98?? I don't have Windows 98
handy. Can someone try it and let me know if those two statments work
in Windows 98 without causing it to chock?

Thanks
 
Re: batch commands work in Win XP but not 98

Re: batch commands work in Win XP but not 98

eganders wrote:
> On Mar 3, 7:52 pm, "PCR" <pcr...@netzero.net> wrote:
>> eganders wrote:
>>
>> | Why do the following commands result in garbage stored in tractest.txt
>> | for Windows 98, but puts the date and time headings into the file
>> | "tracetest.txt" for Windows XP as I want? Can these statements be
>> | changed in some way so that the date and time are stored in the file
>> | properly?
>> |
>> | date >> tracetest.txt < nul
>> | time >> tracetest.txt < nul
>>
>> Instead of nul, try to input the ENTER key-- but I don't know how to do
>> it! (Nul, for me, created a monstrosity of a file! No one else should
>> ever try it!)
>>
>> Alternatively, look for something here...http://home7.inet.tele.dk/batfiles/batfiles.htm
>>
>> But I haven't been able to find it, myself, after 1/2 hour's study!
>>
>> | I have a batch file that puts the date and time in the header of a
>> | section of a file prior to running a test. I need to identify the
>> | date and time that the test is run. Each time the test is run, the
>> | date and time are placed in the file and the test and the results are
>> | stored in the file appended to the results of the last test run. This
>> | works just fine for Windows XP, but creates a long file filled with
>> | garbage characters when either of these statements are run for Windows
>> | 98.
>> |
>> | microsoft.public.win98.gen_discussion
>>
>> --
>> Thanks or Good Luck,
>> There may be humor in this post, and,
>> Naturally, you will not sue,
>> Should things get worse after this,
>> PCR
>> pcr...@netzero.net

>
> Someone suggested
>
> echo %date% >> tracetest.txt
> echo %time% >> tracetest.txt
>
> for Windows XP and it created a much better header of just the date
> and time instead of a bunch of garbage around it.
>
> However, does it work with Windows 98?? I don't have Windows 98
> handy. Can someone try it and let me know if those two statments work
> in Windows 98 without causing it to chock?
>
> Thanks


eganders:

Just tried both suggested command lines and all I get is a text file with:

ECHO is on

for each time the command line is run.

HTH & GL

John

--
\\\||///
------------------o000----(o)(o)----000o----------------
----------------------------()--------------------------
'' Madness takes its toll - Please have exact change. ''

John Dulak - Gnomeway Services - http://tinyurl.com/2qs6o6
 
Re: batch commands work in Win XP but not 98

Re: batch commands work in Win XP but not 98

eganders wrote:
> On Mar 3, 7:52 pm, "PCR" <pcr...@netzero.net> wrote:
>> eganders wrote:
>>
>> | Why do the following commands result in garbage stored in tractest.txt
>> | for Windows 98, but puts the date and time headings into the file
>> | "tracetest.txt" for Windows XP as I want? Can these statements be
>> | changed in some way so that the date and time are stored in the file
>> | properly?
>> |
>> | date >> tracetest.txt < nul
>> | time >> tracetest.txt < nul
>>
>> Instead of nul, try to input the ENTER key-- but I don't know how to do
>> it! (Nul, for me, created a monstrosity of a file! No one else should
>> ever try it!)
>>
>> Alternatively, look for something here...http://home7.inet.tele.dk/batfiles/batfiles.htm
>>
>> But I haven't been able to find it, myself, after 1/2 hour's study!
>>
>> | I have a batch file that puts the date and time in the header of a
>> | section of a file prior to running a test. I need to identify the
>> | date and time that the test is run. Each time the test is run, the
>> | date and time are placed in the file and the test and the results are
>> | stored in the file appended to the results of the last test run. This
>> | works just fine for Windows XP, but creates a long file filled with
>> | garbage characters when either of these statements are run for Windows
>> | 98.
>> |
>> | microsoft.public.win98.gen_discussion
>>
>> --
>> Thanks or Good Luck,
>> There may be humor in this post, and,
>> Naturally, you will not sue,
>> Should things get worse after this,
>> PCR
>> pcr...@netzero.net

>
> Someone suggested
>
> echo %date% >> tracetest.txt
> echo %time% >> tracetest.txt
>
> for Windows XP and it created a much better header of just the date
> and time instead of a bunch of garbage around it.
>
> However, does it work with Windows 98?? I don't have Windows 98
> handy. Can someone try it and let me know if those two statments work
> in Windows 98 without causing it to chock?
>
> Thanks


eganders:

Or try this site:

http://www.huweb.hu/maques/realdate.htm#variable

John

--
\\\||///
------------------o000----(o)(o)----000o----------------
----------------------------()--------------------------
'' Madness takes its toll - Please have exact change. ''

John Dulak - Gnomeway Services - http://tinyurl.com/2qs6o6
 
Re: batch commands work in Win XP but not 98

Re: batch commands work in Win XP but not 98

On Mar 3, 6:16 pm, eganders <egand...@yahoo.com> wrote:
> On Mar 3, 7:52 pm, "PCR" <pcr...@netzero.net> wrote:
>
>
>
>
>
> > eganders wrote:

>
> > | Why do the following commands result in garbage stored in tractest.txt
> > | for Windows 98, but puts the date and time headings into the file
> > | "tracetest.txt" for Windows XP as I want?  Can these statements be
> > | changed in some way so that the date and time are stored in the file
> > | properly?
> > |
> > | date >> tracetest.txt < nul
> > | time >> tracetest.txt < nul

>
> > Instead of nul, try to input the ENTER key-- but I don't know how to do
> > it! (Nul, for me, created a monstrosity of a file! No one else should
> > ever try it!)

>
> > Alternatively, look for something here...http://home7.inet.tele.dk/batfiles/batfiles.htm

>
> > But I haven't been able to find it, myself, after 1/2 hour's study!

>
> > | I have a batch file that puts the date and time in the header of a
> > | section of a file prior to running a test.  I need to identify the
> > | date and time that the test is run.  Each time the test is run, the
> > | date and time are placed in the file and the test and the results are
> > | stored in the file appended to the results of the last test run.  This
> > | works just fine for Windows XP, but creates a long file filled with
> > | garbage characters when either of these statements are run for Windows
> > | 98.
> > |
> > | microsoft.public.win98.gen_discussion

>
> > --
> > Thanks or Good Luck,
> > There may be humor in this post, and,
> > Naturally, you will not sue,
> > Should things get worse after this,
> > PCR
> > pcr...@netzero.net

>
> Someone suggested
>
> echo %date% >> tracetest.txt
> echo %time% >> tracetest.txt
>
> for Windows XP and it created a much better header of just the date
> and time instead of a bunch of garbage around it.
>
> However, does it work with Windows 98??  I don't have Windows 98
> handy.  Can someone try it and let me know if those two statments work
> in Windows 98 without causing it to chock?
>
> Thanks- Hide quoted text -
>
> - Show quoted text -


It will not work in Win98 because neither %date% nor %time% are valid
unless you do some more work to assign them values properly - XP is
likely to do this automatically. Another area of contention is the
proper use of double greater than signs. Only one should be used in
the first line to force the creation of the file tracetest.txt and
then two should be used on the second line to cause the second line of
text to be added to the existing file of the same name. Otherwise the
file gets bigger each time it's run with two redirection markers and
it also never gets cleared out of old values.

It's really not fair asking for help on two lines taken out of context
like that - your answers very much will not be usable unless we know
fully what you are trying to do in toto. Other newsgroups are a much
more viable place to get answers that will work - you will still be
required to reveal your hand so to speak.
 
Re: batch commands work in Win XP but not 98

Why not use VBS?
----------------------------------------------------------------------
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Documents and
Settings\Gryst\Desktop\tracetest.txt", ForAppending, True)
f.WriteLine now
f.Close
WScript.Quit
-----------------------------------------------------------------------------

Edit the above to show correct path to tracetest.txt, save as
"timestamp.vbs". To call from a batch file, use the following:

WSCRIPT "full path to timestamp.vbs"

(I am attaching a copy in case the above got line-wrapped.)

--
Gary S. Terhune
MS-MVP Shell/User
www.grystmill.com

"eganders" <eganders@yahoo.com> wrote in message
news:03d2aa01-5b21-41b4-817a-c29f43fa9955@x41g2000hsb.googlegroups.com...
> Why do the following commands result in garbage stored in tractest.txt
> for Windows 98, but puts the date and time headings into the file
> "tracetest.txt" for Windows XP as I want? Can these statements be
> changed in some way so that the date and time are stored in the file
> properly?
>
> date >> tracetest.txt < nul
> time >> tracetest.txt < nul
>
> I have a batch file that puts the date and time in the header of a
> section of a file prior to running a test. I need to identify the
> date and time that the test is run. Each time the test is run, the
> date and time are placed in the file and the test and the results are
> stored in the file appended to the results of the last test run. This
> works just fine for Windows XP, but creates a long file filled with
> garbage characters when either of these statements are run for Windows
> 98.
>
> microsoft.public.win98.gen_discussion
 
Re: batch commands work in Win XP but not 98

On Mon, 3 Mar 2008 13:23:54 -0800 (PST), eganders <eganders@yahoo.com>
put finger to keyboard and composed:

>Why do the following commands result in garbage stored in tractest.txt
>for Windows 98, but puts the date and time headings into the file
>"tracetest.txt" for Windows XP as I want? Can these statements be
>changed in some way so that the date and time are stored in the file
>properly?


Win9x batch language is no where near as powerful as NT class batch
language.

>date >> tracetest.txt < nul
>time >> tracetest.txt < nul


>I have a batch file that puts the date and time in the header of a
>section of a file prior to running a test. I need to identify the
>date and time that the test is run. Each time the test is run, the
>date and time are placed in the file and the test and the results are
>stored in the file appended to the results of the last test run. This
>works just fine for Windows XP, but creates a long file filled with
>garbage characters when either of these statements are run for Windows
>98.


The following single command line will append the date and time to a
filename of your choice. Watch out for word wrap.

%COMSPEC% /CFOR %%v IN (1 2) DO PROMPT $D $T $_ | FIND "-" >>
filename.ext

Another less elegant solution is ...

echo.| date | find "Current" >> filename.ext

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
 
Re: batch commands work in Win XP but not 98

On Mon, 3 Mar 2008 19:52:04 -0500, "PCR" <pcrrcp@netzero.net> put
finger to keyboard and composed:

>Alternatively, look for something here...
>http://home7.inet.tele.dk/batfiles/batfiles.htm


I have taken the liberty of reposting the following FAQ notice (from
Prof Timo Salmi):

===================================================================
Dear new alt.msdos.batch and alt.msdos.batch.nt readers,

Before posing a question you first might wish to take a look at the
following pointers involving the batch/script questions frequently
asked in these newsgroups.

Windows Command Line Interface script programming links
http://lipas.uwasa.fi/~ts/http/http2.html#cmdscript

MS-DOS+Win../95/98/Me batch programming links
http://lipas.uwasa.fi/~ts/http/http2.html#batch

207709 Feb 23 2008 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
Http link format http://garbo.uwasa.fi/pub/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

254761 Nov 11 2005 ftp://garbo.uwasa.fi/pc/link/tsbat.zip
Http link format http://garbo.uwasa.fi/pub/pc/link/tsbat.zip
tsbat.zip Useful MS-DOS batch files and tricks, T.Salmi

The main scopes of these newsgroups are
alt.msdos.batch MS-DOS+Win../95/98/Me batches
alt.msdos.batch.nt NT/2000/XP/.. scripts

Please define your OS when posing a batch/script question.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
===================================================================


- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
 
Re: batch commands work in Win XP but not 98

On Wed, 05 Mar 2008 05:19:25 +1100, Franc Zabkar
<fzabkar@iinternode.on.net> put finger to keyboard and composed:

>The following single command line will append the date and time to a
>filename of your choice. Watch out for word wrap.
>
>%COMSPEC% /CFOR %%v IN (1 2) DO PROMPT $D $T $_ | FIND "-" >>
>filename.ext


You can add your own comments as follows:

%COMSPEC% /CFOR %%v IN (1 2) DO PROMPT Started at $T on $D $_ | FIND
"-" >> filename.ext

.... and ...

%COMSPEC% /CFOR %%v IN (1 2) DO PROMPT Finished at $T on $D $_ | FIND
"-" >> filename.ext

To add a blank line ...

echo.>> filename.ext

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
 
Re: batch commands work in Win XP but not 98

Franc Zabkar wrote:
> On Wed, 05 Mar 2008 05:19:25 +1100, Franc Zabkar
> <fzabkar@iinternode.on.net> put finger to keyboard and composed:
>
>> The following single command line will append the date and time to a
>> filename of your choice. Watch out for word wrap.
>>
>> %COMSPEC% /CFOR %%v IN (1 2) DO PROMPT $D $T $_ | FIND "-" >>
>> filename.ext

>
> You can add your own comments as follows:
>
> %COMSPEC% /CFOR %%v IN (1 2) DO PROMPT Started at $T on $D $_ | FIND
> "-" >> filename.ext
>
> ... and ...
>
> %COMSPEC% /CFOR %%v IN (1 2) DO PROMPT Finished at $T on $D $_ | FIND
> "-" >> filename.ext
>
> To add a blank line ...
>
> echo.>> filename.ext
>

If your local date format doesn't use "-", use something like this:

%COMSPEC% /CFOR %%v IN (1 2) DO PROMPT $D $T Started $_ | FIND /v "$_"
> logfile2.txt


I prefer date time fields to be sortable, YMMV.
 
Re: batch commands work in Win XP but not 98

Re: batch commands work in Win XP but not 98

eganders wrote:
| On Mar 3, 7:52 pm, "PCR" <pcr...@netzero.net> wrote:
|> eganders wrote:
|>
|> | Why do the following commands result in garbage stored in
|> | tractest.txt for Windows 98, but puts the date and time headings
|> | into the file "tracetest.txt" for Windows XP as I want? Can these
|> | statements be changed in some way so that the date and time are
|> | stored in the file properly?
|> |
|> | date >> tracetest.txt < nul
|> | time >> tracetest.txt < nul
|>
|> Instead of nul, try to input the ENTER key-- but I don't know how to
|> do
|> it! (Nul, for me, created a monstrosity of a file! No one else should
|> ever try it!)
|>
|> Alternatively, look for something
|> here...http://home7.inet.tele.dk/batfiles/batfiles.htm
|>
|> But I haven't been able to find it, myself, after 1/2 hour's study!
|>
|> | I have a batch file that puts the date and time in the header of a
|> | section of a file prior to running a test. I need to identify the
|> | date and time that the test is run. Each time the test is run, the
|> | date and time are placed in the file and the test and the results
|> | are stored in the file appended to the results of the last test
|> | run. This works just fine for Windows XP, but creates a long file
|> | filled with garbage characters when either of these statements are
|> | run for Windows
|> | 98.
|> |
|> | microsoft.public.win98.gen_discussion
|>
|> --
|> Thanks or Good Luck,
|> There may be humor in this post, and,
|> Naturally, you will not sue,
|> Should things get worse after this,
|> PCR
|> pcr...@netzero.net
|
| Someone suggested
|
| echo %date% >> tracetest.txt
| echo %time% >> tracetest.txt
|
| for Windows XP and it created a much better header of just the date
| and time instead of a bunch of garbage around it.
|
| However, does it work with Windows 98?? I don't have Windows 98
| handy. Can someone try it and let me know if those two statments work
| in Windows 98 without causing it to chock?

Nope. As Lee said, more work is necessary to make those work in
pre-irradiated OS's. HOWEVER, looks like Zabcar has solved it with not
horribly convoluted healthy Win98 DOS code...

C:\>echo.| date | find "Current" >> filename.ext

C:\>type filename.ext
Current date is Wed 03-05-2008

C:\>echo.| time | find "Current" >> filename.ext

C:\>type filename.ext
Current date is Wed 03-05-2008
Current time is 8:20:14.25p

OR, you can go & use Terhune's somewhat more horribly convoluted .vbs
way.

| Thanks

You are welcome.

--
Thanks or Good Luck,
There may be humor in this post, and,
Naturally, you will not sue,
Should things get worse after this,
PCR
pcrrcp@netzero.net
 
Back
Top