批处理脚本以获取网站ip地址? [英] Batch script to get website ip address?
本文介绍了批处理脚本以获取网站ip地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一个批处理文件放在一起,它将对一个网站执行ping操作,并将其ip分配给一个变量-我已经搜索过,但实际上还无法将某些内容放在一起.谁能向正确的方向推我.
I'm trying to put together a batch file, that will ping a website, and assign its ip to a variable - I've searched around, but haven't really been able to put something together. Can anyone shove me in the right direction.
蒂姆.
推荐答案
您可以尝试ping命令. 这个想法是获得ping输出的[]之间的部分.
You could try the ping command. The idea is to get the part between the [], of the ping output.
@echo off
setlocal EnableDelayedExpansion
set myServer=google.de
for /f "tokens=1,2 delims=[]" %%a IN ('ping -n 1 !myServer!') DO (
if "%%b" NEQ "" set ip=%%b
)
echo ip is %ip%
这篇关于批处理脚本以获取网站ip地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文