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-06-24 05:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Ask: Batch processing for judging file content and character replacement View 4,206 Replies 16
Original Poster Posted 2006-10-29 06:27 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
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 ]
Floor 2 Posted 2006-10-29 07:01 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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 ~ : )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 3 Posted 2006-10-29 07:17 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  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.  =_=
Floor 4 Posted 2006-10-29 07:32 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Secretly tell everyone, the Ping in Vista is Chinese - localized
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-10-29 10:00

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-10-29 07:44 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
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 ]
Floor 6 Posted 2006-10-29 07:53 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Originally posted by electronixtar at 2006-10-29 07:32:
Secretly tell everyone that the Ping in Vista has been localized


I deleted mine, and I'll post a localized ping.exe for everyone to use.
Floor 7 Posted 2006-10-29 10:01 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Unexpectedly, there is really a Chinese-localized Ping~ : )
Give electronixtar 2 points!
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 8 Posted 2006-10-29 11:13 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  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.
Floor 9 Posted 2006-10-29 12:45 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
I've said it before. The prompt is "Not a valid Win32 program"

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 10 Posted 2006-10-29 22:53 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
@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.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-10-31 02:42
Floor 11 Posted 2006-10-29 23:50 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
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=
Floor 12 Posted 2006-10-30 00:02 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
It will default to the first =
The display effect is the same as the above moderator
Floor 13 Posted 2006-10-30 01:20 ·  中国 河北 廊坊 联通
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
What youxi01 said, I have tested it and it was successful.
Welcome youxi01, are you still hanging out in the batch processing forum?
Floor 14 Posted 2006-10-30 02:36 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Haha, yeah.
I often browse here too, and I've learned a lot of things.
Floor 15 Posted 2006-10-31 02:15 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Originally posted by youxi01 at 2006-10-29 22:53:
@echo off
set for=于
set of=的
set with=用
set in=(以
set data:=数据
set milli-seconds:=毫秒为单位)
set Approximate=大约
set times=时间:
set round=来回
set trip=行程
s ...


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.
Forum Jump: