Home Page
  • April 18, 2024, 10:27:30 pm *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  


Official site launch very soon, hurrah!

Author Topic: Ping URL  (Read 8780 times)


  • Programmer Person
  • Administrator
  • Hero Member
  • *****
  • Posts: 536
    • View Profile
    • Dakusan's Domain
Ping URL
« on: December 23, 2010, 11:32:33 am »

Original post for Ping URL can be found at https://www.castledragmire.com/Posts/Ping_URL.
Originally posted on: 12/23/10

The following is a Python script that automatically pings a requested web address at a given interval. It was made as a quick favor for a friend. Here is the downloadable source code and Windows binary.

The Configuration Options File (PingURL.cfg) contains 2 lines:
  1. The URL to ping (The default pings the GetIP script)
  2. The millisecond interval between pings (Default=600000=10 minutes)

from sys import stderr
from urllib import urlopen
from time import localtime, strftime, sleep

#Main function
def Main():
   #Open the settings file
   Settings=[] #Blank out settings file variable in case it can't be opened
       Settings=open(SettingFileName, 'r').readlines()
   except IOError as (errno, strerror):
       stderr.write('Cannot open {0} configuration file: I/O error({1}): {2}\n'.format(SettingFileName, errno, strerror))

   #Confirm valid settings were passed
       stderr.write('Not enough settings found in settings file\n')
       stderr.write('Invalid interval time\n')
   #Ping the URL indefinitely
           URLText='READ FAILED'
       print 'URL Pinged At {0}: {1}'.format(strftime('%Y-%m-%d %H:%M:%S', localtime()), URLText)

#Run the program