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 10:28
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » What does "ping -n 1 127.1 > nul" mean? View 18,253 Replies 73
Original Poster Posted 2006-10-25 02:15 ·  中国 河北 沧州
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
As the question says: I saw the statement "ping -n 1 127.1>nul" in several batch files. What does "ping -n 1 127.1>nul" mean? Can the experts explain it?
Floor 2 Posted 2006-10-25 02:17 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Start/Run hh ntcmds.chm::/ntcmds.htm
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-10-25 02:19
Floor 3 Posted 2006-10-25 02:20 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
It mainly plays a role in delay, and there seems to be nothing else. 127.1 is the loopback address of this machine, which is equivalent to 127.0.0.1. Not only can 127.0.0.1 be written in the form of 127.1, but other types of IP addresses can also be, for example: 61.0.0.28 can also be written in the form of 61.28.
我今后在论坛的目标就是做个超级坏人!!!
Floor 4 Posted 2006-10-25 02:28 ·  中国 河北 沧州
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
Oh, I see. Thank you, two friends!
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
amtf15 +1 2008-10-22 17:41
Floor 5 Posted 2006-10-25 08:23 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
### About `ping -n 1 127.1>nul:`

1. `ping` is a network command to test network connectivity. The parameter "-n 1" means sending only one ICMPS packet to test network connectivity.

2. `127.1` represents the local reserved IP address, which is actually 127.0.0.1. Pinging 127.1 means pinging 127.0.0.1, which can test whether the network card and TCP/IP protocol are installed and working properly.

3. `>nul` means redirecting the screen display information generated by the command (>) to the null device (nul), so that the execution result of the ping command is not displayed on the screen. If you want to block error messages, you can use `>nul 2>nul` to block all screen output.
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
Billunique +4 2007-09-21 01:38
majj +1 2008-02-16 01:07
Floor 6 Posted 2006-10-25 10:38 ·  IANA 局域网IP(Private-Use)
新手上路
Credits 11
Posts 5
Joined 2006-10-19 09:15
19-year member
UID 66825
Gender Male
Status Offline
If you want to block error messages, you can use ">nul 2>nul" to block all screen output.

This sentence is not very understandable -_-
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+1 2010-09-19 23:47
公道不在人心,是非只在时势
Floor 7 Posted 2006-10-25 11:04 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Re: xyxFlysky
  The ">nul 2>nul" can block all screen output. Here's the understanding:

  Suppose you execute a command but don't want to see the execution result on the screen. You can use " >nul" to block the output of the command on the screen. But some commands may produce error messages, and even using ">nul" can't block the information they generate. So adding " 2>nul" after it, that is, " >nul 2>nul", in this way, whether the command runs correctly or not, you won't see the screen display generated by this command.

  Let's take a simple example.

  The "dir" command can display the file and folder list of the current directory. At this time, if you use "dir >nul", you won't see the screen output of the dir command. Then what will happen if you type "dirr"? At this time, it will display " 'dirr' is not an internal command, nor an external command, nor a batch file." Then you may use "dirr >nul" to block this error message, but I tell you, your guess is wrong because the error message " 'dirr' is not an internal command, nor an external command, nor a batch file." will still appear. At this time, if you use "dirr >nul 2>nul", you won't see the above error message on the screen. I don't know if you understand it now.

  If you want to know more about the explanation of nul, you can search in the forum. You can find the detailed and wonderful explanation of the usage of nul by brother willsort.


[ Last edited by lxmxn on 2006-10-26 at 12:33 AM ]
Recent Ratings for This Post ( 7 in total) Click for details
RaterScoreTime
sglxy +6 2006-10-25 18:56
beeny +2 2007-01-20 11:45
baomaboy +2 2007-03-18 03:43
zhxy9804 +2 2007-03-22 10:57
haiou327 +2 2007-07-08 23:40
Nickey +2 2008-02-15 18:02
+1 2009-11-17 22:39
Floor 8 Posted 2006-10-25 18:55 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
Brother lxmxn, your explanation is very detailed and has helped me understand the puzzles that I couldn't figure out before. I really appreciate your patient guidance, thank you!
Floor 9 Posted 2006-10-25 20:45 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
The example is really vivid, appreciate it~ :)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 10 Posted 2006-10-26 00:05 ·  美国 缅因州
中级用户
★★
Credits 316
Posts 152
Joined 2006-06-18 13:01
20-year member
UID 57204
Gender Male
Status Offline
Brother lxmxn has a very cool avatar, and he himself is very patient. Thumbs up!
Floor 11 Posted 2006-10-26 03:00 ·  中国 北京 连邦软件股份有限公司
新手上路
Credits 10
Posts 4
Joined 2006-10-25 04:13
19-year member
UID 68149
Gender Male
Status Offline
If you understand Linux, it's easy to understand the concept of the null device
Floor 12 Posted 2006-10-29 00:49 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Ping -n 1 127.1>nul How to use this? I just want a similar usage. That is, executing ping -n 1 127.1>nul it will have no information. Then why execute it?

[ Last edited by yangzhiyi on 2006-10-29 at 12:51 AM ]
Floor 13 Posted 2006-10-29 00:53 ·  中国 浙江 温州 电信
中级用户
★★
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 00:49:
How to use the command "ping -n 1 127.1>nul"? I'm exactly looking for a similar usage.
That is, when you execute "ping -n 1 127.1>nul", there will be no any information. Then what is the purpose of executing it?
Please paste the original text for me to see.



Using the ping command to make the script run with a delay, that is, waiting for a few seconds before running the following.

I don't know the precision. :D

I use wscript.sleep:D
Floor 14 Posted 2006-10-29 01:02 ·  中国 广东 茂名 电信
中级用户
★★
Credits 261
Posts 123
Joined 2006-06-06 19:23
20-year member
UID 56648
Status Offline
Crazy, the step-by-step execution of batch commands still needs to use delays. Usually, it's done with jumps. Using ping -n 1 127.1>nul for delays is even crazier.
Floor 15 Posted 2006-10-29 01:11 ·  中国 北京 鹏博士BGP
初级用户
Credits 29
Posts 14
Joined 2006-08-02 15:19
19-year member
UID 59683
Status Offline
1 2 3 5 Next ›
Forum Jump: