WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

TCPIP and IP Address

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IP Detector and Email Notification

Keywords:   IP address

AddExtender("wwipg32i.dll")   ;Ping Extender
AddExtender("WWWSK32I.DLL")   ;EMAIL extender

;Debug (@ON)

;******* String ID *******
TimeOut=2
TimeLoopOfPing=30

IPAdress="127.0.0.1"     ;Enter your own IP Adress to scan!

;;EMAIL Stuffs
WhoFrom = "YourEMAIL@Domain.net"        
WhoTo   = "SendToEMAIL@Domain.net"       
mserver = "SMTP Server Adress"          
dasubj  = "IP Error notification report" 
damsg   = "The current IP adresse (%IPAdress%) is unreachable. Error msg.: %err%"   




;******* Ping it buster *******
:Home

x=ipPing(IPAdress,TimeOut)
If x == 1
  Delay(TimeLoopOfPing) 
  Goto Home
EndIf

;***** First time cant reach the IP adress *******
x=1
x=ipPing(IPAdress,TimeOut)
If x ==1 then goto home 

;******* Oups, i really can't reach the IP adress *******
err=ipGetLastErr()


Gosub ErrorID
Gosub SendEmail
Message("Error reaching the IP Adress: %IPAdress%","%err% - %rc%")

Exit

;******************************************  
:ErrorID
Error = err - 11000
Switch Error
    case 1
            err="IP_BUF_TOO_SMALL"
            break
    case 2
            err="IP_DEST_NET_UNREACHABLE"
            break
    case 3
            err="IP_DEST_HOST_UNREACHABLE"
            break
    case 4
            err="IP_DEST_PROT_UNREACHABLE"
            break
    case 5
            err="IP_DEST_PORT_UNREACHABLE"
            break
    case 6
            err="IP_NO_RESOURCES"
            break
    case 7
            err="IP_BAD_OPTION"
            break
    case 8
            err="IP_HW_ERROR"
            break
    case 9
            err="IP_PACKET_TOO_BIG"
            break
    case 10
            err="IP_REQ_TIMED_OUT"
            break
    case 11
            err="IP_BAD_REQ"
            break
    case 12
            err="IP_BAD_ROUTE"
            break
    case 13
            err="IP_TTL_EXPIRED_TRANSIT"
            break
    case 14
            err="IP_TTL_EXPIRED_REASSEM"
            break
    case 15
            err="IP_PARAM_PROBLEM"
            break
    case 16
            err="IP_SOURCE_QUENCH"
            break
    case 17
            err="IP_OPTION_TOO_BIG"
            break
    case 18
            err="IP_BAD_DESTINATION"
            break

;The next group are status codes passed up on status indications to transport layer protocols.

    case 19
            err="IP_ADDR_DELETED"
            break
    case 20
            err="IP_SPEC_MTU_CHANGE"
            break
    case 21
            err="IP_MTU_CHANGE"
            break
    case 22
            err="IP_UNLOAD"
            break
    case 23
            err="IP_ADDR_ADDED"
            break
    case 50
            err="IP_GENERAL_FAILURE"
            break
    case 255
            err="IP_PENDING"
            break

    case response                               ; default case
            err="IP_GENERAL_FAILURE_MAX_IP_STATUS"
            break
EndSwitch

return


;***** Send EMAIL Error Message ***** 
:SendEmail
rc = smtpSendText (mserver, whofrom, whoto, dasubj, damsg)
Return







Article ID:   W14737
Filename:   IP Detector and Email Notification.txt
File Created: 2001:03:13:16:40:10
Last Updated: 2001:03:13:16:40:10