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-20 12:19
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » What does "ping -n 1 127.1 > nul" mean? View 18,258 Replies 73
Floor 16 Posted 2006-10-29 01:13 ·  中国 浙江 温州 电信
中级用户
★★
Credits 458
Posts 196
Joined 2006-10-05 12:04
19-year member
UID 64614
Status Offline
Originally posted by yangzhiyi at 2006-10-29 01:02:
Crazy, for batch commands that need to be executed step by step and also require delays, usually jumps are used. Using ping -n 1 127.1>nul for delays is even crazier.


Some commands take a relatively long time to get results, and if the next step needs to use the results, you need to delay for a while before running the next step

It's impossible to keep jumping around all the time o.o
Floor 17 Posted 2006-10-29 01:26 ·  中国 北京 鹏博士BGP
初级用户
Credits 29
Posts 14
Joined 2006-08-02 15:19
19-year member
UID 59683
Status Offline
Originally posted by zerocq at 2006-10-29 01:13:


Some commands take a long time to get results. If the next step needs to use the results, you need to delay for a while before running the next step

It's impossible to keep jumping around o.o


Generally, can start /w be used to solve the situation of waiting for results?
Floor 18 Posted 2006-10-29 02:33 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline


Usually, can starting with start /w solve the situation of waiting for the result?

Using the start command will open a new CMD window or other program windows, which is not appropriate in some cases.

And in many cases, using the ping command can play a certain role, and the time can be set arbitrarily by you, although the accuracy is not very good. In batch processing, the ping command is still used in many places to achieve the purpose of delay.
Floor 19 Posted 2006-10-29 03:23 ·  中国 广东 深圳 罗湖区 电信
新手上路
Credits 6
Posts 3
Joined 2006-10-28 05:58
19-year member
UID 68606
Gender Male
Status Offline
Not bad! Worth praising!~
Floor 20 Posted 2006-10-29 03:30 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
If in the batch command, there is no need for delay at all. The result is relatively slow, but the next step偏偏 needs to use the result. The next step will not be reached until this step is not completed. If this step is completed, the next step also has the result available. DOS commands have only one pointer.
If other programs or files are called in the batch processing, start /w will do, and there is no problem of a new window.

I only know that choice is used to delay and then automatically input the value,
I really don't know how to apply this delay.
If you want multiple batch processes to run simultaneously, and the obtained results need to be used by each other, this kind of application should be wrong. Could this be multi-threading under DOS.
Floor 21 Posted 2006-10-29 04:06 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
choice delay : choice /t 120 /d y

The delay unit is seconds, and the above is a delay of 120 seconds.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lbccyxs +2 2008-03-14 17:07
Floor 22 Posted 2006-10-29 07:46 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  If a command executes relatively slowly and the next command needs to use the result of this command, you can use the command connectors "&&" and "||". For example: "command 1 && command 2 || command". In this way, if command 1 is executed successfully, command 2 is executed. If it is not executed successfully, command 3 is executed. It can also be understood that command 2 is only executed after command 1 is executed successfully.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lbccyxs +2 2008-03-14 17:09
Floor 23 Posted 2006-10-29 08:18 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Originally posted by lxmxn at 2006-10-29 07:46:

  If a command executes relatively slowly, and the next command needs to use the result of this command, then you can use the command connectors "&&" and "||", uh..


But command 3 also needs to be executed after command 1 is completed.
Floor 24 Posted 2006-10-29 08:25 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by yangzhiyi at 2006-10-29 08:18:


But command 3 also needs to be executed after command 1 is completed.


  Then what is your purpose to achieve?
Floor 25 Posted 2006-10-29 08:44 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Hehe, I have understood what this command is for.
Floor 26 Posted 2007-02-10 05:55 ·  中国 广东 广州 电信
中级用户
★★
Credits 210
Posts 85
Joined 2007-01-14 12:38
19-year member
UID 76501
Gender Male
From 广东广州
Status Offline
Win98 or pure DOS does not support >nul 2>nul. How to achieve blocking all screen output?
Floor 27 Posted 2007-02-10 06:00 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
ctty nul

Restore with ctty con
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
lizaoyou +2 2007-02-10 06:18
Floor 28 Posted 2007-02-10 06:22 ·  中国 广东 广州 电信
中级用户
★★
Credits 210
Posts 85
Joined 2007-01-14 12:38
19-year member
UID 76501
Gender Male
From 广东广州
Status Offline
Thanks to qzwqzw for the guidance! It solved the problem that had been bothering me for a long time.
Floor 29 Posted 2007-02-10 14:19 ·  中国 贵州 贵阳 电信
初级用户
Credits 97
Posts 45
Joined 2007-01-31 06:02
19-year member
UID 78190
Gender Male
Status Offline
I can't figure out why it's | directly under DOS but || is needed in BAT
Floor 30 Posted 2007-02-16 14:08 ·  中国 湖北 武汉 电信
新手上路
Credits 14
Posts 6
Joined 2007-02-16 13:47
19-year member
UID 79638
Gender Male
Status Offline
Learned about >nul, , , , good stuff
Forum Jump: