Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created February 22, 2010 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommorris/311495 to your computer and use it in GitHub Desktop.
Save tommorris/311495 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "ping"
begin
here = Ping.pingecho("tom-morriss-ipod.local")
rescue Exception => e
# do nothing
end
if here == true
`fe`
end
How to find out your iPod touch/iPhone's .local domain:
on the machine you want to run the above script on, run
`python -m SimpleHTTPServer`
This sets up a simple HTTP server. Note the port number - usually 3000 or 8000.
then in the iPhone browser, go to that server.
In the shell, read the logs.
Tom-Morriss-iPod.local - - [22/Feb/2010 20:59:00] "GET / HTTP/1.1" 200 -
Now attempt to ping the device - make sure it is turned on and not sleeping.
After a few minutes of inactivity, it stops responding to pings.
Now, if you are using OS X, that should all just work.
I'm using it from Ubuntu and Debian machines. If you can't ping, try installing
Avahi:
- Ubuntu 9.04 (Jaunty Jackalope) - should be installed by default
- older Ubuntu - sudo aptitude install avahi-daemon
- probably same for Debian
As for 'fe' - that's a shell script I wrote that updates my FireEagle.
Without any argument, it sets it to default.
If you wanted to update Foursquare (for your home? Are you nuts?!),
you could add another line to the script under fe:
`curl -u "EMAIL:PASSWORD" -d "twitter=0&facebook=0&vid=#{venue_id}" http://api.foursquare.com/v1/checkin.xml`
You have to set the venue_id to the venue_id for your home.
Yeah, if you do that, you are nuts. Or you live in a flat with a good doorman.
------
Also, another comment about the code.
Some might wonder why I haven't put the `fe` block inside the try-catch block.
I've done it because I may want to expand that checking in the future. I thought
initially about doing it twice or thrice - but if it returns true, that is fine by me.
I may want to do a MAC address lookup though using ARP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment