![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 22:24 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » Ask: Batch processing for judging file content and character replacement |
| Printable Version 4,381 / 16 |
| Floor1 yangzhiyi | Posted 2006-10-29 06:27 |
| 中级用户 Posts 123 Credits 261 | |
|
First, determine the content of file 1.txt.
1. If there is Lost = 4, then add "Test failed" at the end of the file. 2. If there is "Reply from", then add "Test passed" at the end of the file. 3. If it is "Ping request could not find host www.*.com Please check the name and try again.", then add "Target host name cannot be resolved." at the end of the file. 4. If there is "TTL Expired in Transit", then add "The number of required hops exceeds the 'Time to Live' (TTL)." at the end of the file. 5. If it is "Destination Host Unreachable", then add "There is no local or remote route to the target host on the sending host or router." at the end of the file. _______________________________________________ If there is the following information: Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<1ms TTL=64 Request timed out. Reply from 127.0.0.1: bytes=32 time<1ms TTL=64 Reply from 127.0.0.1: bytes=32 time<1ms TTL=64 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms ______________________________________________________ Then replace it with the following. ______________________________________________________ Pinging 127.0.0.1 with 32 - byte data: (It is also acceptable to replace it with Pinging 127.0.0.1 is sending with 32 - byte data) Reply from 127.0.0.1: bytes = 32 time < 1ms TTL = 64 Reply timed out. Reply from 127.0.0.1: bytes = 32 time < 127.0.0.1's Ping statistics: (It is also acceptable to replace it with Ping statistics for 127.0.0.1:) Packets: Sent = 4, Received = 4, Lost = 0 (0% loss) Approximate round trip times in milliseconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms ________________________________________________________ For NT systems such as 2000/XP, use the commands of the system to complete. 127.0.0.1 may be other IPs, that is, there are other files such as 2.txt, 3.txt, etc., and 127.0.0.1 may be 192.168.0.1 or www.21cn.com, etc. It is just a part of the functions in batch processing. You can use all methods such as jumps, calls, generation, etc., but the commands must be built - in to the system. If replacement is too troublesome, you can first make judgments. Ping seems to only return the above 5 kinds of results. Say thank you first, and may check it on Monday. [ Last edited by yangzhiyi on 2006 - 10 - 29 at 08:12 AM ] |
|
| Floor2 redtek | Posted 2006-10-29 07:01 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Is this too personalized? Haha...
And it's all in Chinese, which is very uncomfortable to read : ) It's better to directly localize Ping.exe ~ : ) |
|
| Floor3 lxmxn | Posted 2006-10-29 07:17 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Hehe. I agree with the person above. Since the original poster already knows the meaning of the English inside, why change it to Chinese? And it seems a bit awkward. =_= |
|
| Floor4 electronixtar | Posted 2006-10-29 07:32 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Secretly tell everyone, the Ping in Vista is Chinese - localized
|
|
| Floor5 yangzhiyi | Posted 2006-10-29 07:44 |
| 中级用户 Posts 123 Credits 261 | |
|
You're all right. I just want to localize the information returned by ping.
Of course I understand those meanings, but I'm doing this for people who don't understand, so I still need everyone's help. If replacing is too troublesome, you can first make a judgment. Ping seems to only return 5 kinds of information. [ Last edited by yangzhiyi on 2006-10-29 at 08:06 AM ] |
|
| Floor6 yangzhiyi | Posted 2006-10-29 07:53 |
| 中级用户 Posts 123 Credits 261 | |
Originally posted by electronixtar at 2006-10-29 07:32: I deleted mine, and I'll post a localized ping.exe for everyone to use. |
|
| Floor7 redtek | Posted 2006-10-29 10:01 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Unexpectedly, there is really a Chinese-localized Ping~ : )
Give electronixtar 2 points! |
|
| Floor8 lxmxn | Posted 2006-10-29 11:13 |
| 版主 Posts 4,938 Credits 11,386 | |
|
It is suggested that the LZ extracts the ping command in Vista and puts it into the system directory of NT for direct use. I don't know if it is compatible or not. |
|
| Floor9 electronixtar | Posted 2006-10-29 12:45 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
I've said it before. The prompt is "Not a valid Win32 program"
|
|
| Floor10 youxi01 | Posted 2006-10-29 22:53 |
| 高级用户 Posts 247 Credits 846 From 湖南==》广东 | |
|
@echo off
set for=于 set of=的 set with=用 set in=(以 set data:=数据 set milli-seconds:=毫秒为单位) set Approximate=大约 set times=时间: set round=来回 set trip=行程 set Reply=应答 set from=来自 set bytes=字节 set time=时间: set timed=时间 set out=超过 set statistics=统计 set Packets:=包: set Sent=已发送= set Received=已收到= set Lost=已丢失= set loss)=丢失) set Minimum=最小值= set Maximum=最大值= set Average=平均值= set TTL=TTL= setlocal enabledelayedexpansion for /f "delims=" %%i in ('ping www.21cn.com') do ( set ret= for %%a in (%%i) do if defined %%a (set ret=!ret!!%%a!) else set ret=!ret! %%a if not "!ret!"=="" (set ret=!ret:time=时间! && echo !ret!) else echo. ) pause>nul Explanation: The above code did not fully meet the building owner's requirements and the translation is not very accurate. Also, the building owner's content judgment is not made here. |
|
| Floor11 不得不爱 | Posted 2006-10-29 23:50 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
The following code is incorrect! The set cannot have 2 =, but the following equal signs can be written as ^=
set Sent=Sent= set Received=Received= set Lost=Lost= set loss)=Loss) set Minimum=Minimum= set Maximum=Maximum= set Average=Average= |
|
| Floor12 youxi01 | Posted 2006-10-30 00:02 |
| 高级用户 Posts 247 Credits 846 From 湖南==》广东 | |
|
It will default to the first =
The display effect is the same as the above moderator |
|
| Floor13 ccwan | Posted 2006-10-30 01:20 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
What youxi01 said, I have tested it and it was successful.
Welcome youxi01, are you still hanging out in the batch processing forum? |
|
| Floor14 youxi01 | Posted 2006-10-30 02:36 |
| 高级用户 Posts 247 Credits 846 From 湖南==》广东 | |
|
Haha, yeah.
I often browse here too, and I've learned a lot of things. |
|
| Floor15 yangzhiyi | Posted 2006-10-31 02:15 |
| 中级用户 Posts 123 Credits 261 | |
Originally posted by youxi01 at 2006-10-29 22:53: Thanks, but the timeout is incorrect. Can you replace the whole sentence? Also, I don't understand the following. Can you explain it? I want to generate a file for use. |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |