56675 Dec 27 2003 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi, linked
With the version number the file is
ftp://garbo.uwasa.fi/pc/ts/tscmd14.zip
This time added the following items
39} Is there a subroutine to convert a variable into uppercase?
40} How do I get the number of arguments given to a script?
41} How can I create a zero-byte file? How do I test for it?
42} What is the subroutine for testing a filename for wildcards?
43} Is there a way of counting the number of files in a folder?
44} How do I get the first 68 columns from a text file?
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:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
Hi,
just a note about 15):
Is it possible to echo without linefeed like the Unix echo -n?
Yes :
@echo off
set a=E100 BE 82 0 8A 14 B4 2 CD"!"83 C6 1 80"<"D"u"F2 C3
echo exit|cmd/Kprompt $_Nech#.com$_%a%$_rcx$_12$_W$_Q|debug>nul
ech#.com test>test.txt
del ech#.com
Source code of ech#.com:
MOV SI,82
MOV DL,[SI]
MOV AH,02
INT 21
ADD SI,1
CMP BYTE PTR [SI],0D
JNZ 103
RET
Did you really test this in W2k/XP?
"Herbert Kleebauer" <kl...@unibwm.de> wrote in message news:3FEDE036...@unibwm.de...
Of course,why?
you have to run the cmd file from the command prompt,
(or double click)
not copy and paste to the command prompt.
> > > @echo off
> > > set a=E100 BE 82 0 8A 14 B4 2 CD"!"83 C6 1 80"<"D"u"F2 C3
> > > echo exit|cmd/Kprompt $_Nech#.com$_%a%$_rcx$_12$_W$_Q|debug>nul
> > > ech#.com test>test.txt
> > > del ech#.com
> > >
> > > Source code of ech#.com:
> > >
> > > MOV SI,82
> > > MOV DL,[SI]
> > > MOV AH,02
> > > INT 21
> > > ADD SI,1
> > > CMP BYTE PTR [SI],0D
> > > JNZ 103
> > > RET
> >
> > Did you really test this in W2k/XP?
>
> Of course,why?
Because at least in the German version of W2k (in opposite to win9x/NT)
the command line starts at 0x81 instead of 0x82 (the space after the
program name is not stored at 0x81).
After executing the command
ech#.com test>test.txt
the content of test.txt should be "est" for W2k/XP and "test" for
DOS6/Win9x/ME/NT.
"Herbert Kleebauer" <kl...@unibwm.de> wrote in message news:3FEDF7DE...@unibwm.de...
I tested my file in XP and the output is test
In respect to my limited asm knowledge I was so keen and tested it with
a german w2k and the content was:
======copy of screen output=========
C:\test>dumphex test.txt
DumpHex Version 1.0.1
Copyright (c) 2003 Robert Bachmann
00000000h: 74 65 73 74 test
C:\test>
======copy of screen output=========
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
>"Timo Salmi" <t...@UWasa.Fi> wrote in message news:ts20031227...@poiju.uwasa.fi...
>> Sat 27-Dec-2003: The new NT/2000/XP FAQ items still come relevant at
>> a fair pace. Hence made the next update available, as usual as
>>
>> 56675 Dec 27 2003 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
>> tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi, linked
>
>Hi,
>just a note about 15):
>Is it possible to echo without linefeed like the Unix echo -n?
>
>Yes :
>
>@echo off
>set a=E100 BE 82 0 8A 14 B4 2 CD"!"83 C6 1 80"<"D"u"F2 C3
>echo exit|cmd/Kprompt $_Nech#.com$_%a%$_rcx$_12$_W$_Q|debug>nul
>ech#.com test>test.txt
>del ech#.com
Well, that's too short to be a virus, but it's plenty long enough to
be dangerous - users are advised that it is generally considered
pretty stupid to use binary programs downloaded from newsgroups - it
is better to assemble from source, but there is never any reason to
believe that source presented along with a binary is actually the
source for that binary. It is less difficult to write a script to
create the binary from the source (using DEBUG) than it is to write a
script to create the same program from hex or ASCII, if the source is
available - inclusion of both raises alarms all over the place,
though, of course, it could be just someone trying to show off rather
than offer safe and usable assistance to someone who asked a question.
T.E.D. (tda...@gearbox.maem.umr.edu - e-mail must contain "T.E.D." or my .sig in the body)
> @echo off
> set a=E100 BE 82 0 8A 14 B4 2 CD"!"83 C6 1 80"<"D"u"F2 C3
:
> Source code of ech#.com:
> MOV SI,82
Similarly, the sister package for MS-DOS+Win..95/98/Me
243153 Dec 27 2003 ftp://garbo.uwasa.fi/pc/link/tsbat.zip
tsbat.zip Useful MS-DOS batch files and tricks, T.Salmi
contains
ECHON.EXE echo -n, Echo without a linefeed Oct-14-2001 07:28:02
which works also on NT/2000/XP (or at least XP, since I can't test
the others).
@echo off & setlocal enableextensions
C:\_F\BAT\ECHON Testline 1
C:\_F\BAT\ECHON Testline 2
C:\_F\BAT\ECHON Testline 3
endlocal & goto :EOF
D:\TEST>cmdfaq
Testline 1Testline 2Testline 3
Many the tsbat.zip solutions not necessarily included in tscmd.zip
work for NT/2000/XP. However, the reverse is not true. Most of the
code in tscmd.zip is not valid for MS-DOS+Win..95/98/Me.
> >Because at least in the German version of W2k (in opposite to win9x/NT)
> >the command line starts at 0x81 instead of 0x82 (the space after the
> >program name is not stored at 0x81).
> >
> >After executing the command
> >
> >ech#.com test>test.txt
> >
> >the content of test.txt should be "est" for W2k/XP and "test" for
> >DOS6/Win9x/ME/NT.
>
> In respect to my limited asm knowledge I was so keen and tested it with
> a german w2k and the content was:
>
> 00000000h: 74 65 73 74 test
Now I'm really surprised. I currently don't have a W2k available, so
I have to wait till "next year" to test it. Maybe it was considered
as a bug and fixed in a service pack.
In Win2000 or WinXP (*not* NT 4.0):
<Win2000> c:\cmd>demo\TestNoCRLF
One . . . Two . . . Three.
<Win2000> c:\cmd>rlist demo\TestNoCRLF.cmd
=====begin c:\cmd\demo\TestNoCRLF.cmd ====================
1. @echo off
2. setlocal
3. echo/|set /p =One
4. ping -n 2 127.0.0.1 > nul
5. echo/|set /p = . . . Two
6. ping -n 2 127.0.0.1 > nul
7. echo/ . . . Three.
=====end c:\cmd\demo\TestNoCRLF.cmd ====================
--
Phil Robyn
Univ. of California, Berkeley
u n z i p m y a d d r e s s t o s e n d e - m a i l
Phil, your solution is by far the best presented. Well done yet
again! Yours does not require anything external. But why the line 4
at all?
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:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
> Phil, your solution is by far the best presented. Well done yet
> again! Yours does not require anything external.
Based on your solution, added
Comments:
http://www.google.com/groups?selm=bsm4uq$e6f4a$1...@ID-55492.news.uni-berlin.de
Phil's solution in the comment demonstrates that this task can be
solved without external tools. The solution below is based on Phil's
posting. Note the ^quoting of 1, 2, and 3 lest they be taken as
handles.
@echo off & setlocal
echo.|set /p=Testline ^1>tmp.txt
echo.|set /p=Testline ^2>>tmp.txt
echo.Testline ^3>>tmp.txt
for %%c in (type del) do %%c tmp.txt
endlocal
The output will be
D:\TEST>cmdfaq
Testline 1 Testline 2 Testline 3
"Timo Salmi" <t...@UWasa.Fi> wrote in message news:bsmehs$c...@poiju.uwasa.fi...
> In article <bsmctg$b...@poiju.uwasa.fi>, Timo Salmi <t...@UWasa.Fi> wrote:
> > Phil Robyn <zipp...@uclink.berkeley.edu> wrote:
> > > 3. echo/|set /p =One
> (snip)a
>
> > Phil, your solution is by far the best presented. Well done yet
> > again! Yours does not require anything external.
>
> Based on your solution, added
>
> Comments:
> http://www.google.com/groups?selm=bsm4uq$e6f4a$1...@ID-55492.news.uni-berlin.de
>
> Phil's solution in the comment demonstrates that this task can be
> solved without external tools. The solution below is based on Phil's
> posting. Note the ^quoting of 1, 2, and 3 lest they be taken as
> handles.
> @echo off & setlocal
> echo.|set /p=Testline ^1>tmp.txt
> echo.|set /p=Testline ^2>>tmp.txt
> echo.Testline ^3>>tmp.txt
> for %%c in (type del) do %%c tmp.txt
> endlocal
> The output will be
> D:\TEST>cmdfaq
> Testline 1 Testline 2 Testline 3
Can you echo the character > without CR LF ?
>In article <bsmctg$b...@poiju.uwasa.fi>, Timo Salmi <t...@UWasa.Fi> wrote:
>> Phil Robyn <zipp...@uclink.berkeley.edu> wrote:
>> > 3. echo/|set /p =One
>(snip)a
Hmm, to use set /P for an echo without crlf is a commonly used technic.
I learned it here several weeks ago. This variant from Phil doesn't use
a "dummy" variable which is creative.
I've used a <NUL to terminate the pseudo input and not an echo cause of
the true pipe with the overhead of a second cmd.
>
>> Phil, your solution is by far the best presented. Well done yet
>> again! Yours does not require anything external.
>
>Based on your solution, added
>
>Comments:
>http://www.google.com/groups?selm=bsm4uq$e6f4a$1...@ID-55492.news.uni-berlin.de
This doesn't work ?
Google has the thread, but not Phil's posting - strange.
http://www.google.com/groups?threadm=3FEE7417.717ABC7C%40unibwm.de
If you use the escape character ^ should be no problem.
See how this selfmodifying batch does it:
::ChangeMyself.cmd:::::::::::::::::::::::::::::::::::::
@echo off & setlocal enableextensions
set /P =echo/echo/This line added to %0 <NUL>add2me.cmd
echo/^>^>%0>>add2me.cmd
call add2me.cmd
del add2me.cmd
:::::::::::::::::::::::::::::::::::::::::::::::::::::::
>echo/^>%0>>add2me.cmd
I can't see the echoed > character !
Not so fast :-). Google has a delay, which usually is up to a day. I
took the message-id from the original posting's headers, not from
Google. But now it seems to have gotten there.
Yes, I should have this better commented.
The set statement above puts this into the intermediate file add2me.cmd:
echo/echo/This line added to (however you name the file) >EOF no crlf!
the echo then appends ">(however you name the file)
If you took my naming the file add2me.cmd looks like this:
echo/echo/This line added to ChangeMyself.cmd >>ChangeMyself.cmd
Since this intermediate file is deleted afterwards you can't see that.
But if you got the line "This line..." echoed it had functioned.
Uno's question :
>>Can you echo the character > without CR LF ?
Is though answered by example. Even if the proof is deleted - if the
first ">" wouldn't have been output the second one would have messed up
the runnning cmd file.
The short delay provided by line 4 makes it easier to see what is
really happening.
Any "commonly used technic" once was new. And as far as I remember,
Phil was the first who used this method at least in this news group.
--
If he's the originator all honours belong to him.
If I'd known, I'd mentioned it.
Actually, I think that it was Frank Westlake who first used this technique
in this newsgroup. :-)
I think it was Al. I found a post of his dated nine months before Frank was aware of
the technique:-
Subject: ECHO without terminating CRLF - was "Re: com1 input"
Newsgroups: microsoft.public.win2000.cmdprompt.admin
Date: 2002-02-15 21:08:44 PST
http://groups.google.com/groups?threadm=%23qRDtfqtBHA.2608%40tkmsftngp04
Subject: Re: Progress Bar
Newsgroups: microsoft.public.win2000.cmdprompt.admin
Date: 2002-11-21 03:34:42 PST
http://groups.google.com/groups?threadm=01c29151%24d3379950%240125250a%40mjtfqbuyhrfregky
--
Ritchie
Hi, Ritchie,
Yes, I think you are correct. Thanks for making me go back and read these
old posts. I had completely forgotten about using SET /P to write the
'poison' characters to a file without prefacing them with carets.
<nul (set /p z="<this>|<is>|<only>|<a>|<TEST>")>out.txt
EKKO, via sig line 3, will echo any combination of characters, and
appends none automatically. It copies standard input first, and can be
used to generate < & >, for example.
It should work on anything with some DOS compatibility.
Is the format of Oct-14-2001 forced on unwilling Finns by MS, or is it a
personal or national preference?
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
Sheesh! Even *I* don't have the time to go googling through the archives to
prove I did something first! I hope you manage to get out at least a little
bit over the holidays, Ritchie. ;-)
/Al
PS: and thanks for the Christmas present!
As I recall, Frank was mainly into NT4. His comment in the second thread
above must have come shortly after he started dabbling in w2k, otherwise I
am quite sure he would have beaten me to this one too.
And speaking of Frank... ?
/Al
Thank you guys,
for the extra lesson - I'll take it as a christmas gift :-)
--
Greetings
Matthias
> I think it was Al. I found a post of his dated nine months before Frank was aware of
> the technique:-
> Subject: ECHO without terminating CRLF - was "Re: com1 input"
> Newsgroups: microsoft.public.win2000.cmdprompt.admin
Thank you. I'll be insterting two reference links:
http://www.google.com/groups?selm=%23qRDtfqtBHA.2608%40tkmsftngp04
http://www.google.com/groups?selm=bsm4uq$e6f4a$1...@ID-55492.news.uni-berlin.de
There is "value-added" in both the postings.
"Timo Salmi" <t...@UWasa.Fi> wrote in message news:bsocb3$n...@poiju.uwasa.fi...
> Ritchie <qiournvdlirh...@hotmail.com> wrote:
> > "Phil Robyn" <zipp...@uclink.berkeley.edu> wrote in message news:bsnhcd$ekr9d$1...@ID-55492.news.uni-berlin.de...
> > > Actually, I think that it was Frank Westlake who first used this technique
>
> > I think it was Al. I found a post of his dated nine months before Frank was aware of
> > the technique:-
>
> > Subject: ECHO without terminating CRLF - was "Re: com1 input"
> > Newsgroups: microsoft.public.win2000.cmdprompt.admin
>
> Thank you. I'll be insterting two reference links:
> http://www.google.com/groups?selm=%23qRDtfqtBHA.2608%40tkmsftngp04
> http://www.google.com/groups?selm=bsm4uq$e6f4a$1...@ID-55492.news.uni-berlin.de
> There is "value-added" in both the postings.
I found another way to echo without crlf:
ech test>test.txt
ech test2>>test.txt
Carry on like this and soon you'll have a Google mirror <g>
--
Ritchie
Ok :-). Seriously, though. Credit where credit is due. And not
sensible to reproduce everything. Yet, the references are only a
small part the whole, and each item hopefully is self-contained
enough to serve in a FAQ.
Yes. In the last one, Phil uses the technique with a nul variable name -
surely a good way to code to show that the intent is not to accept a new
value for an environment variable.
/Al
Ech, that's way uglee. Or at least it uses something not native to 2k/xp.
/Al
Just tried it in: W2k 5.00.2195 Service Pack 2:
00000 65 73 74 est
This means that cmd.exe was modified in a service pack > 2.