Skip to content

Instantly share code, notes, and snippets.

@mansouryaacoubi
Last active July 18, 2017 12:21
Show Gist options
  • Save mansouryaacoubi/4689189a114fa7bd336fe902072d0c9e to your computer and use it in GitHub Desktop.
Save mansouryaacoubi/4689189a114fa7bd336fe902072d0c9e to your computer and use it in GitHub Desktop.
Continuous host reachability check (Batch on Windows using Ping)
@echo off
set url=%1
mode con cols=70 lines=1
color 37
::color 17
:check
IF %url%. EQU . (
set /P url=Host:
goto check
)
:loop
ping %url% -n 1 2>&1 > nul
set EL=%ERRORLEVEL%
cls
IF %EL% EQU 0 <nul set /p =[SUCCESS] Host (%url%) reachable
IF %EL% EQU 1 <nul set /p =[ERROR ] Host (%url%) unreachable
timeout 1 2>&1 > nul
goto loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment