Skip to content

Instantly share code, notes, and snippets.

@gcch
Created January 26, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcch/69d09483744d611ec2504d1656c48936 to your computer and use it in GitHub Desktop.
Save gcch/69d09483744d611ec2504d1656c48936 to your computer and use it in GitHub Desktop.
@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