Skip to Content
Palm and Treo Hacks
book

Palm and Treo Hacks

by Scott MacHaffie
October 2005
Beginner to intermediate
240 pages
5h 45m
English
O'Reilly Media, Inc.
Content preview from Palm and Treo Hacks

Receive Alerts on the Go

How can you find out if your web server is down? You can set up your desktop to notify your Palm device when something happens.

You shouldn’t have to manually checkto see if your web site is up or not. Technology should be able to handle mundane chores like this. If you have a smartphone or wireless Palm device, then why not have it alert you when something goes wrong?

On your desktop machine, set up a simple script that checks to make sure your web site is alive. If the web site is down, then the script can send a text message (SMS) or an email [Hack #35] to your Palm device to let you know.

Test the following Python script out to make sure it works for you. Also, try running it with a non-existent URL to verify that the notification is working. Once the script is working, you can set up a cron job (Linux or Macintosh) or add it to Scheduled Tasks for Windows XP.

The Code

 """Check to see if a given web site is up or not. Usage: python check_site.py <URL> """ import os, sys, urllib2, smtplib # The following variables should be redefined to fit your system _smtp_server = "outgoing.example.com" # If you need to use SMTP AUTH, set this to 1. # You will also need to set an SMTP user name and SMTP password _authentication_required = 0 _user = "" _password = "" _to = "user@example.com" _from = "webserver@mydomain.com" _num_tries = 3 def is_site_up(url): """Checks to see if the given site is up""" try: urllib2.urlopen(url) return True except: return False def check_site(url): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Car PC Hacks

Car PC Hacks

Damien Stolarz
Google Hacks

Google Hacks

Tara Calishain, Rael Dornfest

Publisher Resources

ISBN: 059610054XCatalog PageErrata