Advertisements

 

Recent comments
« Installing Fedora 11 on my Asus EEE 701 4g Surf | Main | Analyzing IIS server logs »
Wednesday
Jun242009

Fun with iPhone push



Yesterday the AIM messenger on the iPhone was launched with push service. When you install and run the app, it will ask you if you want push enabled. Push will keep a persistent connection with the APNS (Apple Push Notification Servers) of Apple. Any app that uses push, will use these servers to deliver messages to your phone.

The fun thing is that you don't have to run the app itself anymore to receive messages. You can 'turn off' the iPhone and still get a notification for the app on which you have enabled push on. So I was wondering what you could do with push and came up with an cheap web2iphone script that i've put on my personal blog. Members can post a message in a box and it will 'instantly' (within a couple of seconds) be delivered to my iPhone. You will need a iPhone with a dataplan to get this working. Switching off the iPhone will set it to use the gprs or 3G connection of the phone. I tested it overnight and the push app seemed to use about 15kb per 12 hours. 

 

Here's the setup: I've got AIM running on my home computer and a process that is 'tail-ing' a file remotely via ssh:

bash-3.2$ ssh vim@remote "tail -f /var/www/html/datafile.txt" >> messages.log

On my webserver if made a simple php script that writes the text that is submitted in the form to a file called datafile.txt. The script isn't that special, but to be complete, i'll include it here:

<?php
// Get the form variables using POST
$post=stripslashes($_POST['Message']);
$time = time();
$date = date('l jS \of F Y h:i:s A', $time) ."\n";

// write to the file
$myfile="datafile.txt";
$fh = fopen($myfile, 'a') or die("can't open file");
fwrite($fh, "MESSAGE $post $date
");
fclose($fh);

echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv=\"REFRESH\" content=\"3;url=http://originalurl\"></HEAD>
<body>
Text Send
</body>
</html>";
?>

Next we need a script to send the new messages to the running AIM app. For that i wrote a bash script that communicates with iChat using applescript (osascript). iChat support AIM accounts (oscar protocol). The bash script will tail the 'messages.log' file and will send a message when a new line is written to the messages.log. 

#!/bin/bash
# tailing messages.log until a string is found
#

tail -0f messages.log | (
while true; do
  read var; printf "[%s]\n" $var
  if [[ $var = *MESSAGE* ]]; then
    echo "Found MESSAGE line";
   HOUR=`TZ=GMT+12 date +%H`
   #We don't want our nights to be disturbed
   if [[ $HOUR =~ (23|24|00|01|02|03|04|05|06|07) ]]
        then
        echo "HOUR = between 23 and 07"
    else
   #limit the number of characters to 180 and strip the MESSAGE from the beginning
   STRIPPED=`echo $var| sed -e 's/^MESSAGE//' |  sed -e 's/^\(.\{180\}\).*/\1/'`

   #communicate with iChat
   echo "tell application \"iChat\" to send \"$STRIPPED\" to account \"AIM:youraimname\"" | /usr/bin/osascript
  fi
fi;
done
)

That's it. No need for SMS messages anymore :) Here's a ugly simplified picture to explain it:

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: coertrvar
    cooloeltpa

Reader Comments (7)

Hi, would you like fun games and humour, check out this new iphone app called iSICKO

http://bit.ly/986BGN

February 3, 2010 | Unregistered Commenterjane

This is a good article,thank you for your share,I like it very much.Our products are superior in quality and moderate in price and are sure to be saleable in your market,by virtue of this superior quality, this product is often sold out in many areas. This new product is really much better than the previous one. You have to try it to believe it.replica designer handbags|

September 16, 2010 | Unregistered Commenterreplica designer handbags

Top Selling Bridesmaid Dresses are very popular, so you should buy some Top Selling Bridesmaid Dresses,Junior Bridesmaid Dresses are also very popular, so you should buy someJunior Bridesmaid Dresses,Short Bridesmaid Dresses are also very popular, so you should buy someShort Bridesmaid Dresses,Long Bridesmaid Dresses are also very popular, so you should buy someLong Bridesmaid Dresses,Simple Bridesmaid Dresses are also very popular, so you should buy someSimple Bridesmaid Dresses,Evening Dresses 2011 are also very popular, so you should buy someEvening Dresses 2011,Sexy Evening Dresses are also very popular, so you should buy someSexy Evening Dresses,Elegant Evening Dresses are also very popular, so you should buy someElegant Evening Dresses,Short Evening Dresses are also very popular, so you should buy someShort Evening Dresses,Long Evening Dresses are also very popular, so you should buy someLong Evening Dresses,Plus Size Evening Dresses are also very popular, so you should buy somePlus Size Evening Dresses.Faviana a short Carolina Bang dress.Full Katherine Heigl dress are also fantastic. Allure is essential element of JESSICA BIEL DRESS too.
Dresses for semi formal occasions could be a bit less textured compared to formal functions. It doesn’t need to be full length but short plus size wedding dresses will also do. Faviana Style: 6216 is a short Carolina Bang dress. It is stretch satin dress with back closure, sweetheart neckline and thick straps.Summer Wedding Dresses is made in black, red, teal, and white. Dressy pants and overcoats are acceptable. Full Katherine Heigl dress are also fantastic. Allure is essential element of JESSICA BIEL DRESS too. Material choice for dresses must be dressy like silk, velvet, cashmere, brocade, beach wedding dresses.I really loved this post. You write about this topic very well. There are many prized moments in life, why not buy a Hot Prom Dresses. When looking back on photos of your loved one wearing a Simple Wedding Dresses, it will put a smile on your face.
Wedding Guide|Wedding Veils|Wedding Tiara|Wedding Petticoat|Wedding Jewelry|Wedding Gloves|Wedding Accessories|Homecoming Dresses|Evening Dresses|Cocktail Dresses|Ball Gown|Formal Dresses|Girls Princess Dresses|Party Girls Dresses|Holiday Girls Dresses|Flower Girl Dresses|Simple Bridesmaid Dresses|Long Bridesmaid Dresses|Short Bridesmaid Dresses|Junior Bridesmaid Dresses|Bridesmaid Dresses|Sexy Wedding Dresses|Elegant Wedding Dresses|Chic/Modern Wedding Dresses|Classic Wedding Dresses|Simple Wedding Dresses|Reception Wedding Dresses|Beach Wedding Dresses|Wedding Dresses|Bridal Gowns|formal-dresses-for-winter-2010,how-to-buy-formal-dresses,formal-dress-for-women-2011.

January 6, 2011 | Unregistered Commenterplus size wedding dresses

As for Word 2010, Microsoft Office I really like the ribbon effect Microsoft Office 2007. The only really annoying thing so far is Micro office 2010 that once a document is closed, it doesn't show up on the "Recent Documents" list if it is download Office 2010 saved in the temp directory (for example). So, 2010 office if you forget to save your doc to the Office 2007 right place, it may be hard to find. For me, being on the set of the Martha Stewart television show Office Microsoft 2010 was a treat. It was the Office 2010 download second time, actually, because back in October Anduin showcased Office Microsoft Microsoft OneNote on the air for how it was office 2010 professional helping her keep track of everything from her daughter's school information to her holiday gift list to her complete set of Thanksgiving plans. This was simple to install, early loaded onto my new Windows 7 program. Office 2010 I had no problem MS office 2007 linking over old files from my MS office 2010 old computer. Old file information was easy absorbed by the 'New' versions of the various office products and Microsoft outlook 2010 in just a few minutes all my Office 2007 key old data was reasonable so I had very minimal down time. Last week, the Martha Stewart show featured Microsoft office professional 2010 Word in a television segment about office 2010 pro how to make personal holiday cards quickly and easily. As the product guy responsible for most of the Office Microsoft outlook apps, of course I was Office 2007 download tickled by the fact that Office 2010 Microsoft Word was going to be on TV. Word doesn't get much stage time, you understand. She's definitely the behind-the-scenes kind of girl; much like Anduin Havens, who is the art director for the Microsoft Office 2010 Martha Stewart show download Office 2007. Anduin has got to be one of the 2010 Office Microsoft most creative people I've ever met. She's brilliant, she's won an Emmy for her work on creating the Outlook 2010 set of the show, and she made Office 2010 key these beautiful holiday cards office 2010 home in Word, which were featured on the air.

April 13, 2011 | Unregistered CommenterOffice 2010

New York, NY - Appular announces the launch of Push Panic for iPhone and iPod touch, the second of its seven titles scheduled for release this Fall. Push Panic is an exhilarating color-matching puzzle game that includes four action-packed gameplay modes focused on the frantic creation of explosive color-coded combos. Each mode delivers intense challenges that feature a competitive live-ranking system for facing off against friends in this challenging game that is as rewarding to conquer as it is fun to play!

Bible Audio

July 1, 2011 | Unregistered CommenterBible Audio

It’s really a nice and helpful piece of information.!~!~!~!~!~!~!~!~!!
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie uk
Abercrombie Fitch uk
Abercrombie & Fitch uk
Abercrombie and Fitch uk
Abercrombie outlet
Abercrombie online
Abercrcrombie store
Abercrombie shop
Abercrombie
I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie uk
Abercrombie Fitch uk
Abercrombie & Fitch uk
Abercrombie and Fitch uk
Abercrombie outlet
Abercrombie online
Abercrcrombie store
Abercrombie shop
Abercrombie
What a fun pattern! It's great to hear from you and see what you've sent up to.
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Milano
Abercrombie Fitch Milano
Abercrombie & Fitch Milano
Abercrombie and Fitch Milano
Abercrombie Italia
Abercrombie Fitch Italia
Abercrombie and Fitch Italia
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Milano
Abercrombie Fitch Milano
Abercrombie & Fitch Milano
Abercrombie and Fitch Milano
Abercrombie Italia
Abercrombie Fitch Italia
Abercrombie and Fitch Italia
Abercrombie
Abercrombie & Fitch
All of the projects look great! You make it so simple to this. Thanks
Abercrombie and Fitch
Abercrombie Deutschland
Abercrombie Fitch Deutschland
Abercrombie & Fitch Deutschland
Abercrombie and Fitch Deutschland
Hollister Deutschland
Hollister Frankfurt
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Deutschland
Abercrombie Fitch Deutschland
Abercrombie & Fitch Deutschland
Abercrombie and Fitch Deutschland
Hollister Deutschland
Hollister Frankfurt
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie London
Abercrombie Fitch London
Abercrombie & Fitch London
Abercrombie and Fitch London
Abercrombie outlet
Abercrombie online
Abercrcrombie hoodies
Abercrombie men
Abercrombie women
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie London
Abercrombie Fitch London
Abercrombie & Fitch London
Abercrombie and Fitch London
Abercrombie outlet
Abercrombie online
Abercrcrombie hoodies
I am often to blogging and i really appreciate your content.
Abercrombie men
Abercrombie women
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Paris
Abercrombie Fitch Paris
Abercrombie & Fitch Paris
Abercrombie and Fitch Paris
Abercrombie France
Abercrombie Fitch France
Abercrombie and Fitch France
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Paris
Abercrombie Fitch Paris
Abercrombie & Fitch Paris
Abercrombie and Fitch Paris
Abercrombie France
Abercrombie Fitch France
Abercrombie and Fitch France
Hollister
Hollister UK
Hollister London
Hollister outlet
Hollister online
Hollister clothing
Hollister clothes
Hollister sale
Hollister
Hollister UK
Hollister London
Hollister outlet
Hollister online
Hollister clothing
Hollister clothes
Hollister sale
Hollister
Hollister UK
Hollister London
Hollister outlet
Hollister online
Hollister clothing
Hollister clothes
Hollister sale
Hollister
Hollister outlet
Hollister online
Hollister clothing
Hollister clothes
Hollister sale
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie Deutschland
Abercrombie Fitch Deutschland
Abercrombie & Fitch Deutschland
Abercrombie and Fitch Deutschland
Hollister Deutschland
Hollister Frankfurt
tiffany uk
tiffany London
tiffany outlet
tiffany online
The article has really peaks my interest. I am going to bookmark your site and keep checking for new information.
tiffany jewelry
tiffany co
Hollister
Hollister UK
Hollister London
Hollister outlet
Hollister online
Hollister clothing
Hollister clothes
Hollister sale
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie London
Abercrombie Fitch London
Abercrombie & Fitch London
Abercrombie and Fitch London
Abercrombie outlet
Abercrombie online
Abercrcrombie hoodies
Abercrombie men
Abercrombie women
Abercrombie
Abercrombie & Fitch
Abercrombie and Fitch
Abercrombie uk
Abercrombie Fitch uk
Abercrombie & Fitch uk
Abercrombie and Fitch uk
Abercrombie outlet
Abercrombie online
Abercrcrombie store
Abercrombie shop
jack wills
jack wills outlet
jack wills online
jack wills clothing
jack wills uk
jack wills clearance
jack wills sale
A unique discussion merits a comment. I LOVE YOU

September 18, 2011 | Unregistered Commenterddddddddd

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>