JSI Tip 7959. How can I send an email if an IP address does NOT respond to a PING?

Jerold Schulman

April 21, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I have scripted RUThere.bat to send an email to specified users if an IP address that you specify does NOT respond to a PING (Packet InterNet Groper).

The syntax for using RUThere.bat is:

[call] RUThere IPAddress Email [Email2 ... EmailN]

where IPAdress is the IP address you wish to ping, and EmailN is from 1 through N email addresses to notify.

NOTE: RUThere.bat uses BLAT, the freeware command-line SMTP mailer.

RUThere.bat contains:

@echo offif {%2}
<h1><a name="_echo_Syntax_RUThere_IPAddress_Email_Email2_EmailN_amp_exit_b_1_setlocal_set_IP_1_set_email_2_set_AOK_N_call_test_If_AOK_EQU_Y_goto_finish_again_shift_if_2_" id="_echo_Syntax_RUThere_IPAddress_Email_Email2_EmailN_amp_exit_b_1_setlocal_set_IP_1_set_email_2_set_AOK_N_call_test_If_AOK_EQU_Y_goto_finish_again_shift_if_2_">{} @echo Syntax: RUThere IPAddress Email [Email2 ... EmailN]&amp;exit /b 1setlocalset IP=%1set email=%2set AOK=Ncall :testIf "%AOK%" EQU "Y" goto finish:againshiftif {%2}</a></h1>
{} goto :finishset email=%2call :quiet>nul 2>&1goto again:finishif exist "%temp%RUThere.tmp" del /q "%temp%RUThere.tmp"endlocalexit /b 0:testfor /f "Tokens=*" %%i in ('@ping -n 1 %IP%^|findstr /i /c:"Reply from"') do ( set AOK=Y)if "%AOK%" EQU "Y" goto :EOF@echo %IP% does NOT respond.>"%temp%RUThere.tmp"call :quiet>nul 2>&1goto :EOF:quietblat "%temp%RUThere.tmp" -to %email% -s "%IP% does NOT respond."



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like