Hey guys! Need help here!
Ok, so I've got this server. I need a batch file that will ping it, and if the server doesn't respond it sends me an email.
Anyone got ideas? I'm stuck! And I need this for next week!
Pls help!
FC
Ping server & Send mail
Moderator: DosItHelp
Re: Ping server & Send mail
I know I need to use "ping 192.xxx.xxx.xxx 458" to ping the server, but then? How to send an email if packet loss is at 100%?
Re: Ping server & Send mail
You can't send an email by native batch. You could use blat, but you must have access to an email server.
Regards
aGerman
Code: Select all
@echo off &setlocal
ping 192.xxx.xxx.xxx >nul && goto :eof
:: your blat stuff here
Regards
aGerman
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Ping server & Send mail
If for some reason you *don't* need this to be native dos, then I suggest the hostmonitor program:
http://www.ks-soft.net/hostmon.eng/index.htm
Really nice monitoring program.
Otherwise, to expand on what aGerman said -- I have a file I've created called "pingtest", which doesn't send an email but could easily be adapted:
http://www.ks-soft.net/hostmon.eng/index.htm
Really nice monitoring program.
Otherwise, to expand on what aGerman said -- I have a file I've created called "pingtest", which doesn't send an email but could easily be adapted:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set array=-1
ping -n 1 -w 1000 %1|find /i "ttl=">nul
if errorlevel 1 goto down
:up
set /a array+=1
set header%array%=%date% %time% %1 Ping is up.
:uploop
cls
for /l %%a in (0,1,%array%) do echo !header%%a!
echo.
ping -n 1 -w 1000 %1|find /i "ttl=" || ping -n 1 -w 1000 %1|find /i "ttl=" || goto :down
if errorlevel 1 goto down
ping -n 3 -w 800 127.0.0.1 >nul 2>&1
goto uploop
:down
set /a array+=1
set header%array%=%date% %time% %1 Ping is down.
:downloop
cls
for /l %%a in (0,1,%array%) do echo !header%%a!
echo.
ping -n 1 -w 1000 %1|find /i "ttl=" && goto up
ping -n 3 -w 800 127.0.0.1 >nul 2>&1
goto downloop