Bugs in FOR Command Thread Deleted?

  • Thread starter Thread starter kamyers1
  • Start date Start date
K

kamyers1

I posted a message here about 10 minutes ago regarding a bug in the FOR
command of cmd.exe. At first my message showed up, but now it is gone! My
message included code for a few small batch programs to show examples of the
apparent bug that I am running into. Are posts that include code deleted
from this forum...???
 
kamyers1 said:
I posted a message here about 10 minutes ago regarding a bug in the
FOR command of cmd.exe. At first my message showed up, but now it is
gone! My message included code for a few small batch programs to
show examples of the apparent bug that I am running into. Are posts
that include code deleted from this forum...???

Nope. Try using a newsreader instead of the !@#$%^ web interface to these
newsgroups. Try Forte Agent, Thunderbird, or even Windows Mail/Outlook
Express, instead. It's a lot easier to do nearly everything that way. You
can mark messages to be watched, filter the views so you can see replies to
your posts easily, and search.

The Microsoft public news server is msnews.microsoft.com and you can
subscribe to as many groups as you like; no authentication is required.

The following is from a post by MVP Malke ...

-------------------------------------------------------
Here's information on Usenet and using a newsreader:

http://www.elephantboycomputers.com/page3.html#12-09-02 - a brief
explanation of newsgroups
http://michaelstevenstech.com/outlo...ssnewreader.htm
http://rickrogers.org/setupoe.htm
http://support.microsoft.com/defaul...wto/default.asp
- Set Up Newsreader

http://www.dts-l.org/goodpost.htm

http://aumha.org/nntp.htm - list of MS newsgroups
microsoft.public.test.here - MS group to test if your newsreader is
working properly
http://www.mailmsg.com/SPAM_munging.htm - how to munge email address
http://www.blakjak.demon.co.uk/mul_crss.htm - multiposting vs.
crossposting

Some newsreaders for Windows
http://www.forteinc.com/agent/index.php - for Forte
http://www.mozilla.org (Thunderbird does newsgroups)
http://gravity.tbates.org/

-------------------------------------
 
Hi there,

Thanks for your message. I am currently reading the newsgroup directly as
per your suggestion, and don't see my previous post there either. Any ideas
what could have happened? I posted through the Microsoft Communities web
site. Does that web site rountinely throw away posts or something?

Thanks again,
Kevin M.


"Lanwench [MVP - Exchange]"
 
Kevin Myers said:
Hi there,

Thanks for your message. I am currently reading the newsgroup directly as
per your suggestion, and don't see my previous post there either. Any ideas
what could have happened? I posted through the Microsoft Communities web
site. Does that web site rountinely throw away posts or something?

Thanks again,
Kevin M.

It shows in Google Groups:

http://groups.google.com/group/micr...b345235c/faabe1a3bb970e2e?q=#faabe1a3bb970e2e

"Lanwench [MVP - Exchange]"
 
kamyers1 said:
I posted a message here about 10 minutes ago regarding a bug in the FOR
command of cmd.exe. At first my message showed up, but now it is gone!
My
message included code for a few small batch programs to show examples of
the
apparent bug that I am running into. Are posts that include code deleted
from this forum...???

Here is a copy of your post which I found in Google Groups as mentioned by
Bennett Marco. Since this is far from a trivial set of batch files, you
should ask the batch file experts in alt.msdos.batch.nt for advice. They
love this type of challenge.

This is your post:
============
I wrote a couple of simple utilities using the FOR command in .bat files to
simplify string handling. These utilities 1) remove quotes, and 2) extract
the Nth word. They can both 1) process constant text from the command line,
2) process text output from another command entered on the command line, and
3) act as filters for text piped from another command.

Both of these utilities mostly work as intended. However, there is some
kind of problem that frequently results in printing a generally garbled
version of the message "The system cannot find the file". The message is
garbled in such a way as to strongly suggest that memory is somehow being
trashed.


These errors seem to usually (always?) result from using the FOR command
with the /F option to process contant text that has been enclosed in single
quotes, when the FOR command is NOT even being used to work with files. The
errors seem to occur *after* the FOR command has finished processing and is
terminating or cleaning up after itself.


I would appreciate if someone else could test these scripts to see if they
are able to duplicate the same errors that I see, and also to let me know if
you see anything that I am doing wrong. The content of my two scripts is
provided below, along with a simple test script that frequently produces the
error message. The test script runs in a continuous loop and must be
terminated using Ctrl-C when you are ready to quit.


temp.bat:


@echo off


rem Put this in the same folder as the other two files,
rem and run it from a command promp to test them.
rem Theoretically you should see three lines containing
rem "this is a test", followed by three lines with "is",
rem but you will probably also see some garbled
rem "The system cannot find the file" messages.
rem Hit Ctrl-c to exit when you have seen enough.


:start


echo "this is a test"|cmd /c dequote
call dequote /t "this is a test"
call dequote echo "this is a test"
echo.


echo this is a test|cmd /c scan 2
call scan 2 /t this is a test
call scan 2 echo this is a test
echo.


goto start


dequote.bat:


@echo off


:init


if '%1' equ '/?' goto help
if '%1' equ '-?' goto help
if /I '%1' equ '/h' goto help
if /I '%1' equ '-h' goto help


:main


if '%1' equ '' (
rem deQuote as a filter, could return multiple lines
rem for /f "tokens=* usebackq" %%s in (`NullFilter`) do echo %%~s
for /f "tokens=* usebackq" %%s in (`find /v "xyzzyx963852741"`) do
echo %%~s
) else (
if /I '%1' equ '/t' (
rem deQuote text from command line, always a single line
for /f "tokens=1,* usebackq" %%a in ('%*') do echo %%~b
) else (
rem deQuote output from specified command, could return
multiple lines
for /f "tokens=* usebackq" %%o in (`%*`) do echo %%~o
)
)


goto end


:help


echo deQuote.bat
echo Copyright (c) 2009-09-11 by Kevin A. Myers
echo All rights reserved.
echo.
echo Removes enclosing quotes from source text.
echo.
echo Syntax:
echo deQuote
echo deQuote /t <text>
echo deQuote <command>
echo.


:end


scan.bat:


@echo off


:init


if '%1' equ '/?' goto help
if '%1' equ '-?' goto help
if /I '%1' equ '/h' goto help
if /I '%1' equ '-h' goto help


:main


setlocal


if '%1' equ '' (set token=1) else (set token=%~1)


if '%delims%' neq '' set delims=delims=%delims%


if '%2' equ '' (
rem scan as a filter
rem for /f "tokens=%token% usebackq %delims%" %%s in (`NullFilter`)
do echo
%%s
for /f "tokens=%token% usebackq %delims%" %%s in (`find /v
"xyzzyx963852741"`) do echo %%s
) else (
if /I '%2' equ '/t' (
rem scan text from command line
for /f "tokens=2,* usebackq" %%a in ('%*') do (
for /f "tokens=%token% usebackq %delims%" %%t in
('%%b') do echo %%t
)
) else (
rem scan output from specified command
for /f "tokens=1,* usebackq" %%a in ('%*') do (
for /f "tokens=%token% usebackq %delims%" %%o in
(`%%b`) do echo %%o
)
)
)


endlocal


goto end


:help


echo scan.bat
echo Copyright (c) 2009-09-11 by Kevin A. Myers
echo All rights reserved.
echo.
echo Extract token(s) from specified input line(s).
echo Delimiters are taken from a delims environment variable.
echo.
echo Syntax:
echo scan
echo scan <token>
echo scan <token> /t <text>
echo scan <token> <command>
echo.


:end
 
Interesting that my message shows up in Google groups but not on the
newsgroup and not on Microsoft's web site, especially since I didn't post
that message from Google groups. I wonder what gives?

Thanks for the tip.
 
kamyers1 said:
Interesting that my message shows up in Google groups but not on the
newsgroup and not on Microsoft's web site, especially since I didn't post
that message from Google groups. I wonder what gives?

Thanks for the tip.

There appears to be a bug in Microsoft newsgroups: Once every so often a
post or a reply does not show up, perhaps because an automatic filter
objects to some word or phrase. Regardless of this, your batch file is
really outside the scope of a general WinXP newsgroup. You would stand a
better chance of getting a good response if you posted it in
alt.msdos.batch.nt.
 
Back
Top