2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,21 +1,38 @@
|
|||
:: DNS Query Task from Rosetta Code Wiki
|
||||
:: Batch File Implementation
|
||||
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "Temp_File=%TMP%\NSLOOKUP_%RANDOM%.TMP"
|
||||
set "Domain=www.kame.net"
|
||||
|
||||
echo.Domain: %Domain%
|
||||
set "domain=www.kame.net"
|
||||
echo DOMAIN: "%domain%"
|
||||
echo.
|
||||
echo.IP Addresses:
|
||||
|
||||
::The Main Processor
|
||||
nslookup %Domain% >"%Temp_File%" 2>nul
|
||||
for /f "tokens=*" %%A in (
|
||||
'findstr /B /C:"Address" "%Temp_File%" ^& findstr /B /C:" " "%Temp_File%"'
|
||||
) do (
|
||||
set data=%%A
|
||||
echo.!data:*s: =!|findstr /VBC:"192.168." /VBC:"127.0.0.1"
|
||||
)
|
||||
del /Q "%Temp_File%"
|
||||
call :DNS_Lookup "%domain%"
|
||||
echo.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
::Main Procedure
|
||||
::Uses NSLOOKUP Command and a Temporary File
|
||||
::Also uses a dirty "parsing" to detect IP addresses.
|
||||
|
||||
:DNS_Lookup [domain]
|
||||
setlocal enabledelayedexpansion
|
||||
for /f "delims=" %%T in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x09"') do set "TAB=%%T"
|
||||
set "temp_file=%TMP%\NSLOOKUP_%RANDOM%.TMP"
|
||||
|
||||
set "record="
|
||||
for /f "tokens=1* delims=:" %%x in ('nslookup "%~1" 2^>nul') do (
|
||||
set "line=%%x"
|
||||
if "!line:~0,4!"=="Name" set "record=yes"
|
||||
if "!line:~0,5!"=="Alias" set "record="
|
||||
if "!record!"=="yes" (
|
||||
if "%%y"=="" (echo %%x>>"%temp_file%") else (echo %%x:%%y>>"%temp_file%")
|
||||
)
|
||||
)
|
||||
if exist "%temp_file%" (
|
||||
for /f "tokens=*" %%a in (
|
||||
'findstr /BC:"Address" "%temp_file%" ^& findstr /BC:"%TAB%" "%temp_file%"'
|
||||
) do (set "data=%%a"&echo !data:*s: =!)
|
||||
del /q "%temp_file%"
|
||||
) else (echo Connection to domain failed.)
|
||||
goto :EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue