Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Snap and upload iSight pictures on wake from sleep Laptop Macs
I wrote an interesting script that will automatically take a picture when the machine wakes from sleep, then uploads and displays the image on your web site. I initially did this as an anti-theft measure. To make this work, you'll need a few things: You can see the results of my efforts here. Apart from the nauseating effect of seeing my ugly mug over and over, the results are good. I hope to maybe do a timelapse in QuickTime sometime down the track!

[robg adds: I haven't tested this one. You'll need to customize the shell script with your site's FTP details, and remember to make it executable (chmod 755 progname). As explained on the linked site, you'll need to create a .wakeup file in your home directory, containing the full path to the shell script.]
    •    
  • Currently 3.00 / 5
  You rated: 1 / 5 (6 votes cast)
 
[40,715 views]  

Snap and upload iSight pictures on wake from sleep | 13 comments | Create New Account
Click here to return to the 'Snap and upload iSight pictures on wake from sleep' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Snap and upload iSight pictures on wake from sleep
Authored by: jfox95 on Jan 30, '07 08:44:40AM

need some help with the .wakeup file....

how exactly do i need to type the full path ?

oo and do you have to fill out the ftp info for it to work? or do you have to take the part of the script out?



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: kgp on Feb 01, '07 04:31:54AM

I'm not understanding the .wakeup file either. Is that a file that I create that just has the path to the shell script in it or is it a file that sleepwatcher installs that I edit?



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: kgp on Feb 01, '07 02:20:26PM

I am having trouble with the .wakeup file too. Is this a file that I create and save as ".wakeup" in my home folder? I know that "." means that it is a system file and invisible. I'm just not sure what to do here.



[ Reply to This | # ]
filter those images!
Authored by: klktrk on Jan 30, '07 09:04:28AM

Oh my dear anonymous friend. Thanks for the hint, and I appreciate your openness about your life, but you might want to parse through those automated snaps before publicizing them. All the best. It's a fun record of moments.



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: dirtymouse on Jan 30, '07 02:42:43PM

great idea.

BTW: i like the troopie shot

---
dirtymouse - 'fix a troubled Mac' - troubleshooting PDF



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: hessi on Jan 30, '07 03:11:17PM
Thanks for the hint, works perfect. I just made two small adjustments to your script:

mv /Users/USERNAME/Documents/capture/*.jpg /Users/USERNAME/Documents/capture/uploaded/

instead of

rm /Users/USERNAME/Documents/capture/*.jpg

to still have a local copy of the file. And

rm ~/.netrc

to still be able to use ftp.

[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: erfmufn on Jan 30, '07 05:12:08PM

Hi guys,

I'm glad you like the script.. the edits suggested here are definitely good and I've already incorporated the corrections after noticing the error myself. (^_^)

I also have a bit of delay in the script to give me a minute to delete pics if I forget to put pants on.. but yeh a few escaped my attention and a couple of my girlfriend ended up in there!

It's like big brother I know.. and quite embarrassing actually.. but I wanted to share the technique with the community.

Enjoy!

d




[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: freak123 on Jan 31, '07 03:31:41AM
I really appreciate your post. Thanks a lot.
The uploading to a FTP is a solution but I Find more interesting to send the photo by mail.
The image will be displayed correctly in regular mail program (Mail, Thunderbird...) but not on webmail.
You still can gzip the uuencoded image and send the zip as attachment if you want.
I put in comment the FTP part and grab some more info about the position of the computer and it's surrounding network.
Here is the modification to the wakeup.sh script I brought
# Grab some more information
info=$(ifconfig);
info2=$(hostname);

# change to anything you want...
# This to have ino about the gateway and the provider of the thief.
route=$(traceroute -m 6 www.yahoo.com);

# Write to file
echo "INFO" > /var/root/tmp.txt
echo $info >> /var/root/tmp.txt
echo "---" >> /var/root/tmp.txt
echo "HOSTNAME" >> /var/root/tmp.txt
echo $info2 >> /var/root/tmp.txt
echo "---" >> /var/root/tmp.txt
echo "TRACEROUTE" >> /var/root/tmp.txt
echo $route >> /var/root/tmp.txt
echo " "

# Run FTP session to put JPGs in webspace, then delete from /tmp
# chmod 600 ~/.netrc
# ftp -i MYFTP.SERVER.COM

# Send by mail. This is all on one line, no carriage return
(cat /var/root/tmp.txt; uuencode /Users/YOURNAME/Documents/isight/$date /Users/YOURNAME/Documents/isight/$date) | mail john.doe@gmail.com

# Keep it clean
rm /var/root/tmp.txt
mv /Users/YOURNAME/Documents/isight/*.jpg
/Users/YOURNAME/Documents/isight_send/

chmod the file 774
and "roulez jeunesse!"


[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: keyslapper on Jan 31, '07 10:34:14AM

This is a cool idea. I remember seeing the related hint for invalid logins, and I'll be setting them both up when my new MBP arrives on Friday.
I have one suggestion though. I noticed that several of the pics on the upload site are somewhat underexposed - not the ones that were either removed or "thumbed", but the ones showing a dark silhouette. I wonder if there is some way the screen can be flashed bright white to simulate a "camera flash" to get an exposed pic?

Thanks for the hint!



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: dorg on Feb 12, '07 05:45:52PM

Sorry to sound like a complete noob, but I've looked all over for tutorial-type things on how to do this. I don't really have any experience with scripts but I think this is a GREAT idea. Where exactly do I save these scripts and what do I have to substitute where in order for these images to be sent to my Mail? ANY help at all would be greatly appreciated

Thanks
Dorg



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: apollo97 on Oct 26, '07 08:41:25PM

Ok. So i'm brand new to everything. I've been working really hard to try and figure out how to get this to work but I honestly don't know anything about scripting or creating scripts. I understand that I need to get a .wakeup file into my home folder so that sleepwatcher knows to do something. And I believe I type in that .wakeup script file the destination of his shell script. I've copied the script into a text editor and placed in my information instead of the caps and saved it as a .txt in mac HD so that its /security.txt. I've gone into terminal and set the security.txt file to 755. (I think I did at least.) However, I don't know if that is the right thing to do with his script, and I can't seem to be able to create a blank script that just says the destination of that file. Script editor won't let me compile a script that just says /security.txt. Obviously i'm new and I should have been able to do this in 5 seconds... but can anyone upload the actual script files or tell me how to make the files?



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: edwilde on Jun 06, '09 07:52:54AM

Ok, so when I found this hint half the links didn't work. So I did a bit of digging for the greater good, as I still haven't found a good free application which provides the same functionality. I have just set this up on my unibody macbook (running 10.5.7) and it works like a charm.

Updated links (June 2009):

The full shell script (recovered from Google Cache)

#!/bin/bash
#
# iSight Auto Upload Script - by Dylan O'Donnell 2006
#####################################################
# Edit CAPITALS with appropriate details
# Notes : Change file path to a folder without other JPEGs
# : IF you get zero-byte files, try removing the "passive" line from the FTP stuff.
#
#####################################################

# Generate filename based on date stamp
date=$(date +%m%d%y%H%M%S).jpg;

# Take iSight Photo and store in /tmp with datestamp filename
/bin/isightcapture -w 640 -h 480 -t jpg /Users/USERACCOUNT/Documents/$date;

# Wait a little while, if Mac is waking from sleep, needs a moment to connect to network
sleep 60;

# Generate semaphore for connectivity by pinging NASA
isconnected=$(ping -c 1 www.nasa.gov | grep 64 | wc | awk '{print $1}');

# If connected...
if [ "$isconnected" -eq "1" ]; then

# Make .netrc FTP session commands on the fly
cat > ~/.netrc machine WWW.YOURWEBSITE.COM
login USERNAME
password PASS
macdef init
lcd /Users/USERACCOUNT/Documents
cd REMOTE/DIR
passive
prompt
restrict
type binary
prompt
mput *.jpg
quit

EOF

# Run FTP session to put JPGs in webspace, then delete from /tmp
chmod 600 ~/.netrc
ftp -i WWW.YOURWEBSITE.COM
rm /Users/USERACCOUNT/Documents/*.jpg

else
# If not connected.. leave captures there until next time.
echo "No Connection, Image not transferred or deleted.";
fi

You may also want to make a startup item to call this script, since this will only fire if the computer wakes from sleep not from power off.

I cheated and used applescript do shell script "~/.wakeup &" ;)



[ Reply to This | # ]
Snap and upload iSight pictures on wake from sleep
Authored by: tompohl on Jan 24, '10 01:14:53PM
Under OSX 10.5 and 10.6 a non-interractive user script (like sleepwatcher) isn't allowed access to the camera anymore. I've posted a simple tutorial how to get around that limitation! HOWTO: Track your mac

[ Reply to This | # ]