Home All Groups Group Topic Archive Search About
Author
28 Jan 2009 3:12 PM
skepper
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 ------------------------------------------------------------------------ skepper's Profile: http://forums.techarena.in/members/skepper.htm View this thread: http://forums.techarena.in/server-scripting/1111495.htmhttp://forums.techarena.in

Author
28 Jan 2009 4:11 PM
Pegasus (MVP)
Show quote Hide quote
"skepper" <skepper.3mqbnc@DoNotSpam.com> wrote in message
news:skepper.3mqbnc@DoNotSpam.com...
>
> 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.
Are all your drivers up to date? click for free checkup

Author
29 Jan 2009 9:20 AM
skepper
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 = "PingTes***@myDomain.com"
objEmail.To = "Ad***@myDomain.com"
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.htmhttp://forums.techarena.in
Author
30 Jan 2009 10:30 AM
Pegasus (MVP)
Show quote Hide quote
"skepper" <skepper.3mtmlj@DoNotSpam.com> wrote in message
news:skepper.3mtmlj@DoNotSpam.com...
>
> 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 = "PingTes***@myDomain.com"
> objEmail.To = "Ad***@myDomain.com"
> 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.
Author
29 Jan 2009 2:52 PM
OldDog
Show quote Hide quote
On Jan 28, 10:11 am, "Pegasus \(MVP\)" <I.***@fly.com.oz> wrote:
> "skepper" <skepper.3mq...@DoNotSpam.com> wrote in message
>
> news:skepper.3mqbnc@DoNotSpam.com...
>
>
>
>
>
>
>
> > 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.- Hide quoted text -
>
> - Show quoted text -

Or in vbScript, try this one. Watch the wraps.

<------ Begin script ------------------>

strComputer = "Server name or IP" ' Server you are watching

Do While 1<2 'This loop will run forever (i.e., until the script is
manually stopped).
    If IsConnectible (strComputer,"","") Then
    WScript.Sleep 60000 ' wait a minute
    Else
    adminmail = "whoneedstok***@myob.com" ' Who you want it sent to
    '
    smtp = "172.18.100.55" ' smtp mail server name or IP
    Set mailing = CreateObject("CDO.Message")
    Set wshNet = CreateObject("WScript.Network")

    mailing.From = ("itadmi***@myob.com")
    mailing.To = adminmail
    mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/sendusing") = 2
    mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserver") = smtp
    mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserverport") = 25
    mailing.Subject = header & "Ping failed for" & strComputer
    mailing.TextBody = sFullProductionMessage
    mailing.Configuration.Fields.Update
    mailing.Send
    On Error Goto 0

    End If
Loop


Function IsConnectible(strHost, intPings, intTO)
' Returns True if strHost can be pinged.
' Based on a program by Alex Angelopoulos and Torgeir Bakken.
  Dim objFile, strResults

  If intPings = "" Then intPings = 2
  If intTO = "" Then intTO = 750

  Const OpenAsDefault = -2
  Const FailIfNotExist = 0
  Const ForReading = 1

  objShell.Run "%comspec% /c ping -n " & intPings & " -w " & intTO _
    & " " & strHost & ">" & strTempFile, 0, True

  Set objFile = objFSO.OpenTextFile(strTempFile, ForReading, _
    FailIfNotExist, OpenAsDefault)
  strResults = objFile.ReadAll
  objFile.Close

  Select Case InStr(strResults, "TTL=")
    Case 0
      IsConnectible = False
    Case Else
      IsConnectible = True
  End Select
    If objFSO.FileExists(strTempfile) Then
          objFSO.DeleteFile(strTempFile)
    End If
End Function


<------------ End Script ------------------->

Bookmark and Share

Post Thread options