Tuesday 30 April 2013

Make Continuous Ping more advance

I was wonder if i can make my ping command different like more friendly i decided to work on .bat programming to make it if any one of my Server is down, it will show background in RED color and if its up running again, it show background in GREEN.

here is my codes with more explainations:



echo off & cls :: here i define it to be echo off and clear screen
set /p IP=Enter your IP Address : ::i set it friendly to user for asking to enter IP
:top
PING  -n 1 %IP% | FIND "TTL=" :: setup my colors green if its pinging
IF ERRORLEVEL 1 (SET OUT=4F  & echo Request timed out.) ELSE (SET OUT=2F) :: if there a string Request time out, set color to RED
color %OUT%
ping -n 2 -l 10 127.0.0.1 >nul
GoTo top ::loop

Am writing this for those who do the same as me.

Thanks :)

No comments:

Post a Comment