Host Datei-Script
Aus Howtos und Gedankenstuetzen
@echo off
set domain=.domain.de
for /f %%b in (host-liste.txt) do (ping -n 1 %%b%domain% | find /i "ping-statistik")>>liste-server.txt
for /f "tokens=3 delims=: " %%a in (liste-server.txt) do (echo %%a) >>ip-liste.txt
del liste-server.txt
@echo off & setlocal
set "L1=%host-liste.txt"
set "L2=%ip-liste.txt"
set "Ziel=hosts"
if exist "%Ziel%" del "%Ziel%"
set /a Nr=1
for /f "usebackq tokens=1" %%a in ("%L1%") do set "Line1=%%a" & call :ProcessLine
del ip-liste.txt
goto :eof
:ProcessLine
for /f "tokens=1,* delims=:" %%b in ('findstr /n . "%L2%"^|findstr /b "%Nr%:"') do set "Line2=%%c"
echo %Line2% %Line1%>>"%Ziel%"
set /a Nr+=1
Die Datei liest aus der "liste-server.txt" Hostnamen aus und ping dies an. Danach wird die IPAdresse ausgelesen
und dies hinter die Hostnamen in die Hostdatei geschrieben.