有没有可能生成一个批处理文件,让我输入一个商店编号,然后ping该IP。我有一张列有这些店号和IP地址的清单。
我希望用户键入一个门店号码和脚本将关联门店号码与IP。
我怎么才能开始这样做呢?
发布于 2015-10-01 20:52:47
假设您有一个名为list.txt的文件,其中包含一个数字和地址列表,如下所示:
001 google.com
002 stackoverflow.com
003 random.org
004 127.0.0.1您可以使用以下批处理文件调用具有所选号码的ping on地址:
@ECHO OFF
FOR /F "tokens=1,2" %%I IN (list.txt) DO (
IF [%%I] EQU [%1] (
PING %%J
)
)例如(如果将批处理文件命名为ping-selected.bat):
C:\Script>ping-selected 001
Pinging google.com [216.58.209.46] with 32 bytes of data:
Reply from 216.58.209.46: bytes=32 time=6 TTL=58
Reply from 216.58.209.46: bytes=32 time=6 TTL=58
Reply from 216.58.209.46: bytes=32 time=6 TTL=58
Reply from 216.58.209.46: bytes=32 time=6 TTL=58
Ping statistics for 216.58.209.46:
packets: sent = 4, Received = 4, lost = 0 (0% loss),
Approximate round trip times in milli-secounds:
Minimum = 6 ms, Maximum = 6 ms, Average = 6 mshttps://stackoverflow.com/questions/32886743
复制相似问题