Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: send mail if ping fails

Reply
Thread Tools Display Modes

Re: send mail if ping fails

 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      01-28-2009

"skepper" <> wrote in message
news:...
>
> hello to all!
>
> i need script do it :
>
> ping to server
> if pink ok - ping again (loop)
> if ping fail - send mail via telnet
>
> http://www.f2h.co.il/im.php?name=Ping.jpg&src=95181098
>
> Server 2003 R2
> vb?
> Bat ?
> --
> skepper


You could try this batch file:
@echo off
:Again
ping server | find /i "bytes=" || goto Fail
ping localhost -n 60 > nul
goto Again

:Fail
blat.exe /.. /.. /..
Blat.exe is a command line mailer that you can download from a number of
sites.


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      01-30-2009

"skepper" <> wrote in message
news:...
>
> i try it:
>
> PingTest.cmd
> ----------------------------------------------------
> @echo off
> :Again
> ping mis | find /i "bytes=" || goto Fail
> ping localhost -n 60 > nul
> goto Again
>
> :Fail
> call mail.vbs
> ----------------------------------------------------
> the mail.vbs is:
> Set objEmail = CreateObject("CDO.Message")
> objEmail.From = ""
> objEmail.To = ""
> objEmail.Subject = !Attention Message!"
> objEmail.Textbody = "Ping to Server Fail!"
> objEmail.Send
>
> if i remove the line @echo off, i get this masage :
> ping server| find /i "bytes=" || goto Fail
> ping server| find /i "bytes=" || goto Fail
> ping server| find /i "bytes=" || goto Fail
> ping server| find /i "bytes=" || goto Fail
> The process tried to write to a nonexistent pipe.
> The process tried to write to a nonexistent pipe.
> The process tried to write to a nonexistent pipe.
>
> ?
>
>
> --
> skepper
> ------------------------------------------------------------------------
> skepper's Profile: http://forums.techarena.in/members/skepper.htm
> View this thread: http://forums.techarena.in/server-scripting/1111495.htm
>
> http://forums.techarena.in
>


Try this batch file for starters:

@echo off
:Again
ping mis | find /i "bytes=" || goto Fail
ping localhost -n 60 > nul
goto Again

:Fail
echo Ping failed!

Does it work?
==================
I have a few problems with your VB Script. Here they are:
1. Instead of writing
call mail.vbs
you should write
script //nologo c:\mail.vbs

2. Your script lacks the details that are required under
objEmail.Configuration.Fields

3. The line
objEmail.Subject = !Attention Message!"
lacks a double quote after the = character.

If you are not familiar with VB Scripts then you would be much better off
using blat.exe, as I suggested in my first reply.


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: PING fails - use BLAT to send failure message Miles Li [MSFT] Windows Small Business Server 0 10-27-2008 08:44 AM
Re: PING fails - use BLAT to send failure message SteveB Windows Small Business Server 0 10-24-2008 04:04 AM
ping ComputerName often fails Bob DNS Server 7 06-13-2007 07:18 PM
"send to mail recipient" fails Ian T Windows Vista Mail 1 03-28-2007 04:16 AM
Send to mail recipient fails Ian T Windows Vista Mail 2 03-27-2007 06:18 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59