Created
January 26, 2017 15:03
-
-
Save gcch/69d09483744d611ec2504d1656c48936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: ====================================================================== | |
:: | |
:: nslookup | |
:: | |
:: Copyright (c) 2017 tag. | |
:: <http://karat5i.blogspot.jp> | |
:: | |
:: ====================================================================== | |
set hostname= | |
set /p hostname="Hostname> " | |
:: get ip address from hostname... | |
for /f "tokens=1,2,3 usebackq delims= " %%i in (`nslookup -type^=a -retry^=1 -timeout^=0 %hostname% 2^>^&1 ^| findstr /c:^Address /c:^***`) do ( | |
set "head=%%i !head!" | |
set "value=%%j" | |
) | |
for /f "usebackq" %%i in (`echo %head% ^| findstr /c:***`) do set "status=%%i" | |
if "%status%"=="" ( | |
set "ipaddr=%value%" | |
) else ( | |
set "ipaddr=" | |
) | |
echo IP Address: %ipaddr% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment