China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 11:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Ask about the problem of findstr with multiple characters. View 3,253 Replies 2
Original Poster Posted 2011-01-25 04:56 ·  中国 湖南 邵阳 电信
新手上路
Credits 2
Posts 2
Joined 2008-11-20 02:07
17-year member
UID 131501
Gender Male
Status Offline
for /F "tokens=3" %%* in ('test.exe /c 127.0.0.1 ^| findstr "\<1\>"') do cls & echo 密码错误 & goto :max


I can only check one parameter, and this program has four parameters.
1 Password error
2 Connection timeout
3 Unknown error
4 Close connection

Ask: How should this code be written? It's impossible to run test.exe four times?
Hope to get advice from everyone

[ Last edited by hcosoft on 2011-1-25 at 06:12 ]
Floor 2 Posted 2011-01-25 10:34 ·  中国 上海 联通
新手上路
Credits 13
Posts 11
Joined 2010-08-24 11:36
15-year member
UID 172893
Gender Male
From 上海
Status Offline
Use fuzzy matching, and you change the tokens to the fields you want to intercept

. Wildcard: any character
* Repeat: the previous character or category appears zero or more times
^ Line position: start of line
$ Line position: end of line
Character class: any character in the character set
Complement character class: any character not in the character set
Range: any character in the specified range
\x Escape: literal usage of meta - character x
\ Word position: end of word

Specific implementation, send the return text of test.exe for you to see
Floor 3 Posted 2017-08-26 21:08 ·  中国 湖北 武汉 电信
新手上路
Credits 8
Posts 8
Joined 2017-08-21 22:22
8-year member
UID 182480
Gender Male
Status Offline
If you want to match multiple characters at once, you can write it like this:
findstr /c:"Password error" /c:"Connection timed out" /c:"Unknown error" /c:"Close connection"
Forum Jump: