在批处理文件中使用 ping 来确定最快的服务器
我想对我们公司网络中的 2 台服务器执行 ping 操作,并确定哪一个速度最快(基于 ping 的最小 = [n] 毫秒)。然后使用最快的服务器做一些事情。
伪代码:
a = Ping MyServerA
b = Ping MyServerB
if (a < b)
copy from x to c:\
else
copy from y to c:\
PS 请输入一个工作脚本,因为我真的不太了解批处理文件,例如:“for /F”tokens=3“%%a in (reg2.txt) do set MyDocs=%%a”
I want to ping 2 servers in our company network, and determine which is the fastest (based on the Minimum = [n]ms at the and of a ping). Then do something using the fastest server.
Pseudo code:
a = Ping MyServerA
b = Ping MyServerB
if (a < b)
copy from x to c:\
else
copy from y to c:\
P.S. Please type out a working script, because i really do not understand much about batch file things like: "for /F "tokens=3" %%a in (reg2.txt) do set MyDocs=%%a"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码在 FastestServer 变量中获取最快的服务器,因此您可以在任何您希望的命令中使用它,即
copy %FastestServer% ...
:我希望代码是不言自明的并且将按预期工作。如果您还有任何疑问,请发布!
This code get the fastest server in FastestServer variable, so you may use it in any command you wish, i.e.
copy %FastestServer% ...
:I hope the code be self-explanatory and will work as expected. If you have any further question, just post it!