Creating script to take picture and email it

I recently read an article about someone who created an automator script that would take a picture using a MacBook iSight camera and email it each time the MacBook awoke from sleep. Several laptops have been stolen from my workplace and I thought this would be a great way of figuring out the thief were my laptop ever stolen.
When I looked at the script, I noticed that it opens up PhotoBooth and Mail so that the user in front of the computer would see that their picture was being taken and that an email message was sent.
In the name of stealthness, I was hoping to duplicate this process in a unix script. I have a few pieces figured out, but I need some guidance on other issues.
What I know:
1. How to use sleepwatcher to call a unix script upon the MacBook waking.
2. How to take a stealth image using the commandline command "camcapture".
What I would like to know
1. What unix command could I use to check to see if the MacBook has a viable internet connection?
2. If there is a viable connection, send an email with the image taken to a particular email address and with a particular subjectline.
3. If there is not a viable internet connection, save the email and check for a viable internet connection each 5 minutes (or so) and send the email as soon as an internet connection is achieved.
Thank you in advance for any guidance you can offer.

Hi Mahongue,
   I'm sorry for being absent for a while but in your case that seems to have been a good idea. I think you deserve the star more than I because you seemed to have worked it all out. Of course I couldn't tell you what server your e-mail account uses but it doesn't matter that much in the ping statement. If you can ping mail.yahoo.com, I'm sure that would indicate that you have an internet connection that would allow you to send mail to a yahoo account. I see your point about e-mail being the best solution in case you don't have a reliable server of your own. Of course you can get around the dynamic IP address the way I do, with DynDNS.org. They allow you to change your DNS listing programmatically and you do that at boot. Of course that wouldn't allow you to reliably scp to that machine unless it's always up.
   Your idea of testing the return value of ping command will work in principle. I tested it and ping returns an error if either the lookup fails or the ping times out. I've never used the syntax you did in the if clause. What shell are you using? In a Bourne-type shell, you shouldn't need the parentheses. You could use something like:
if ping -c 1 mail.yahoo.com >/dev/null 2>&1; then
   <Invoke Network Usage>
fi
The redirection avoids cluttering the output of your script with the ping output.
If you're interested, the CheckForNetwork function in the /etc/rc.common script is:
# Determine if the network is up by looking for any non-loopback
# internet network interfaces.
CheckForNetwork()
   local test
   if [ -z "${NETWORKUP:=}" ]; then
   test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
   if [ "${test}" -gt 0 ]; then
      NETWORKUP="-YES-"
   else
      NETWORKUP="-NO-"
   fi
   fi
and usage is:
CheckForNetwork
if [ "${NETWORKUP}" = "-YES-" ]; then
   <Invoke Network Usage>
fi
If you copy-and-paste any of this code, be sure to replace the non-breaking spaces used for indention with real spaces.
   Thanks for the link to the mail_files script!! That is really impressive! Naturally I saved it. The link you posted is broken at the moment but it's probably one of those sites that throttle traffic by shutting it down for a while when it's "overused". Maybe you've made him popular. Anyway, I got a version of the same script elsewhere but mine says that the uuencoding is untested. Yours doesn't say that, does it? Have you tested that with your version?
   Dave's script still uses Perl to do base64 encoding. It should still be possible to do this in Perl and there are advantages to letting library code handle certain tasks. That way, if a protocol changes someone will likely upgrade the library for you. I think that on another thread you asked about how to add an attachment in the code that we were discussing on that other thread. However, I thought you said that you had Perl code to do that. I was just suggesting that you put the two together.
Gary
~~~~
   The party adjourned to a hot tub, yes.
   Fully clothed, I might add.
         -- IBM employee, testifying in California State Supreme Court

Similar Messages

  • I used my i pad for the first time to take pictures and videos. Do I download it on my I mac before using it as a power point presentation? I also want to separate my pictures and my videos?

    i used my i pad for the first time to take pictures and videos. Do I download it on my I mac before using it as a power point presentation? I also want to separate my pictures and my videos? This also the first time that I'm using the apple support communities.

    You can import the videos and photos using iPhoto or Image Capture on your Mac.
    Connect the iPad to the Mac with the cable and launch either of those two applications on the Mac. Your iPad should appear as a device in the left side of the app. Click on the iPad name and then you should have access to all of the photos and Vidoes in the camer roll and you can import them onto the Mac.
    Im not sure what the reference is to Power Point in this case. You can use the imported photos and videos in a Power Point presentation after you import them to the Mac.
    Are you trying to create a Slide Show on the iPad? Is that what you mean by a Power Point presentation?

  • Will i be able to listen to music, watch videos and take pictures and sync with itunes without a sim in my locked iphone 5?

    Will i be able to listen to music, watch videos and take pictures and sync with itunes without a sim in my locked iphone 5?

    You will need a SIM to activate it. There is no way around that. The SIM does not have to be active, but it must be from the correct carrier if the phone is carrier locked. Once activated, it can be removed and used like an iPod touch, but if you ever have to restore or update iOS, you will need the SIM to re-activate it.

  • I am using my iPhone 5 to take pictures and have started a blog with pictures. I am not able to do the update on my phone due to lack of memory.

    I am using my iPhone 5 to take pictures and have started a blog with pictures. I am not able to do the update on my phone due to lack of memory. I wanted to know how much difference this will make to my pictures.
    If anyone had suggestions on how to maximize picture quality n use without the update, I'd appreciate it
    <Link Edited By Host>

    If the lack of space on your phone is due to pictures, you may want to consider transferring some (or all) to a computer and deleting them from the phone. That is a good practice even if you have space on the phone. Instructions: http://support.apple.com/kb/ht4083

  • When you back up your Iphone/Ipad it backs up for camera roll. but when you take pictures and it uses photo stream, does that mean there are two copy's of your photos on icloud one set for photo stream and one set for backups?

    When you back up your Iphone/Ipad it backs up your camera roll. but when you take pictures and it uses photo stream, does that mean there are two copy's of your photos on icloud one set for photo stream and one set for backups?

    What do you mean by storage quota, does that mean i could be photo streaming about 1gb of photos and it does not get taken away from my free 5bg.

  • Someone is using faebook to run java script to get data and email from me in windows 8

    someone is using faebook to run java script  to get  data  and  email  from  me in  windows  8

    Is this a developer question?
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • I have an iphone 4s when I take pictures and send them to my computer or someone elses computer they so times appear upside down. Is it because I have windows? Can I do anything about this?

    I have an iphone 4s when I take pictures and send them to my computer or someone else they appear upside down. I have a window operating system. Is there anything I can do to reverse the pictures?

    OK, here's the explanation.  When you take a picture, the iPhone knows what orientation it is in (portrait, landscape, etc.) and adds that information to the picture's EXIF data so it knows which side is up.  Apple devices can decode this information and show the picture right side up when it is viewed.  However, Windows computers cannot do this.  They are not capable of decoding the orientation information added by the iPhone, so they are displayed in a default orientation (which may not be right side up).
    This only happens on Windows machines, and unfortunately there is nothing you can do about it, except use the rotation buttons in Windows picture view to orient the photo correctly.

  • Can i take picture and send the picture to server in virtual mobile

    As the title,can i take picture and send the picture to server by using mobile api such as java mobile media API,or person java or others?
    if it can,can u tell me which API use?

    Hi ericg77,
    Please see my answer in your similar post: Protected files
    Best,
    Sara

  • Script to take pictures of desktop and mail results

    Hi,
    I am reposting as posted before finishing and I can not edit the message, > server tels me I am not allowed to edit.
    I have a headless server. It has a problem I cannot recreate manually.
    It is programmed to do a restart and if this fails to do a forced restart. However when it does the forced restart I would like to know what is happening and why it failed. So I thought if I have it take pictures of the desktop I might see what dialogue boxes are open and hence find what programme is hanging and stopping the restart.
    This is what I found from dev_sleidy (http://discussions.apple.com/thread.jspa?messageID=6670993&#6670993):
    set dFolder to "~/Desktop/screencapture/"
    do shell script ("mkdir -p " & dFolder)
    repeat 2 times -- Repeat 2 times.
    set tTime to do shell script "date +%H%M%S"
    do shell script ("screencapture " & dFolder & tTime & ".png") -- Capture screen.
    delay 30 -- Wait for 30 seconds.
    end repeat
    So far so good it works.
    Now I want this file to be send per email to me, for which it first needs to be compressed, unless I send all the individual pictures which would also be fine as well.
    How would I do this using mail?
    I have broken my head over the script (I am not very good) to no avail. Any help out there?

    01. Code with '.zip' file attached to each e-Mail message.
    -- Code starts here --
    property tAddress : "[email protected]" -- e-Mail address.
    set tFolder to ((path to desktop folder from user domain) as string) & "screencapture" & ":" -- Screen capture folders' path.
    set dFolder to quoted form of (POSIX path of tFolder) -- Screen capture folders' path, in UNIX form.
    repeat -- Infinite loop.
    do shell script ("mkdir -p " & dFolder) -- Create 'screencapture' folder.
    set tTime to do shell script "date +%H%M%S" -- Obtain current time.
    do shell script ("screencapture " & dFolder & tTime & ".png") -- Capture screen.
    do shell script "zip -r -j " & (dFolder & tTime & ".zip") & " " & (dFolder & tTime & ".png") -- 'zip' the '.png' file.
    tell application "Finder" to set tAttachments to files of folder tFolder whose name contains ".zip" -- Obtain list of all '.zip' files.
    if ((count tAttachments) > 0) then -- If list of '.zip' files exist, continue.
    delay 2
    tell application "Mail"
    activate
    set nMessage to make new outgoing message with properties {visible:false, subject:tTime, content:"" & return & return}
    tell nMessage
    make new to recipient at end of to recipients with properties {address:tAddress}
    tell content
    repeat with i in tAttachments -- Cycle through '.zip' files, attaching each to e-Mail message.
    make new attachment with properties {file name:((i as string) as alias)} at after the last paragraph
    end repeat
    end tell
    send -- Send the e-Mail message.
    end tell
    end tell
    delay 3
    do shell script ("rm -rf " & dFolder) -- Delete 'screencapture' folder.
    end if
    delay (60 * 10) -- Delay for 30 minutes.
    end repeat
    -- Code ends here --
    02. Code with '.png' file attached to each e-Mail message.
    -- Code starts here --
    property tAddress : "[email protected]" -- e-Mail address.
    set tFolder to ((path to desktop folder from user domain) as string) & "screencapture" & ":" -- Screen capture folders' path.
    set dFolder to quoted form of (POSIX path of tFolder) -- Screen capture folders' path, in UNIX form.
    repeat -- Infinite loop.
    do shell script ("mkdir -p " & dFolder) -- Create 'screencapture' folder.
    set tTime to do shell script "date +%H%M%S" -- Obtain current time.
    do shell script ("screencapture " & dFolder & tTime & ".png") -- Capture screen.
    tell application "Finder" to set tAttachments to files of folder tFolder whose name contains ".png" -- Obtain list of all '.png' files.
    if ((count tAttachments) > 0) then -- If list of '.png' files exist, continue.
    delay 2
    tell application "Mail"
    activate
    set nMessage to make new outgoing message with properties {visible:false, subject:tTime, content:"" & return & return}
    tell nMessage
    make new to recipient at end of to recipients with properties {address:tAddress}
    tell content
    repeat with i in tAttachments -- Cycle through '.png' files, attaching each to e-Mail message.
    make new attachment with properties {file name:((i as string) as alias)} at after the last paragraph
    end repeat
    end tell
    send -- Send the e-Mail message.
    end tell
    end tell
    delay 3
    do shell script ("rm -rf " & dFolder) -- Delete 'screencapture' folder.
    end if
    delay (60 * 10) -- Delay for 30 minutes.
    end repeat
    -- Code ends here --

  • Script to tail/monitor and email upon activity...

    Hello all,
    First time poster, medium time user.
    I'm looking to create a script that "watches" /var/log/authlog, and emails a user upon any failed or successful login, for 2 specific account. I've exhausted several options, including simply adding a script to /etc/profile for these accounts' logins, but that won't trap unsuccessful logins. Also, I've tried the following: http://search.cpan.org/~mgrabnar/File-Tail-0.99.3/Tail.pm --- but that won't fly in our environment (management decsion).
    Can somebody please help with some ideas?
    Thanks!
    -Bob

    I think your best bet is to write a routine that can parse the dates in the logfile that you're looking through so that you only look at entries after a specified point in time (or will look x mins back through the log), and so you don't double report on extant instances in the log.
    The perl module Date::EzDate could be of use in the prevention of the reinvention of the wheel on the date parsing :)
    pb

  • Script to extract names and email addresses of all recipients of an email

    Hi,
    I have found some scripts which extract email addresses from the content of messages in Mail, but I am looking for something rather different, and wonder if such a script exists, or if someone can help me build one.  I would like to create a tab delimited text file of the first name, last name and email address of all recipients of a given message in Mail.  Most email addresses will be in the format John Doe <[email protected]>.
    Thanks,
    Nick

    Hi,
    nick_harambee wrote:
    I have one outstanding issue, which wasn't included in the original question.  Sometimes email addresses are included in the Name of the recipient, i.e. instead of 'John Doe', it reads 'John Doe ([email protected])'.  Could you script be adapted to delete any block of text (i.e. space delimited) that includes the @ symbol, so that 'John Doe ([email protected])' would return:
    John<tab>Doe<tab>[email protected]
    Use this handler:
    on splitName(t)
        if "@" is in t then -- to remove the address after the name
            set n to -3
        else
            set n to -2 -- normal name
        end if
        set tid to text item delimiters
        set text item delimiters to space
        set l to text items of t
        if (count l) = 1 then -- no space 
            set r to tab & t & tab -- last name only 
        else
            tell l to set r to "" & (items 1 thru n) & tab & (item (n + 1)) & tab
        end if
        set text item delimiters to tid
        return r
    end splitName

  • Script to take pictures of desktop every 10 minutes.

    Hi,
    I have a headless server. It has a problem I cannot recreate manually.
    It is programmed to do a restart and if this fails to do a forced restart. However when it does the forced restart I would like to know what is happening and why it failed. So I thought if I have it take pictures of the desktop I might see what dialogue boxes are open and hence find what programme is hanging and stopping the restart.
    I would also like it to repeat this procedure every (lets say) 10 minutes.
    I have broken my head over the script (I am not very good) to no avail. Any help out there?

    http://discussions.apple.com/thread.jspa?threadID=1476873&tstart=0
    Reposted as forum server disallowed me to edit it.

  • I take pictures and when i try to bring them up big it show up blank

    i have an iphone 4s and when i take pictures it shows up in the camera roll, but when i try to bring up the pictures individually it is completely blank.

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - iOS: Troubleshooting applications purchased from the App Store
    - Unsync all music and resync
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.

  • Why is a photo displayed sideways when emailed. When I take a picture and email it is received  sideways and not like it appeared when sent. I have not had this problem when sending pictures from my IPad or Mac. Thanks for any help M

    It seems when the photo is sent to someone it is received in  a sideways position. I have resent after editing and rotating the picture but is still is not upright.
    Any help would be great.
    Thanks. M

    In my case I take HD video with an Apple iPhone 4S and an iPad 2. These cameras can be just as easily oriented in any of four orientations by hand, or in various iPhone or iPad holders for mounting on a tripod. As long as I stay with Apple or Adobe products for my whole video handling process, I have no problem with software support for orientation
    While there are countless software programs available today that display JPEG images, only a subset of them actually interpret the EXIF Orientation flag. Just like color management, many programs simply display the JPEG image as it is stored, and completely ignore any extra details stored in the file's metadata. The most important of these additional details is the Orientation flag, stored in the JPEG APP1 marker under EXIF IFD0.
    More explanation of this is in the text below.
    Briefly, Apple is doing it right, with their iPhone 4S and iPad 2, the way most High end video cameras do it. And they made sure that their apps looked at the appropriate flag to rotate the image before showing it. To understand this look at this site:
    http://www.impulsead...rientation.html
    This is a site that explains the whole deal. Apple and Adobe are looking at the flags for image rotation. Plex,and many others are not doing so. VLC for instance, DropBox is anpther example, Thunderbird is another example, the list is long.
    Many newer digital cameras (both dSLR and Point & Shoot digicams) have a built-in orientation sensor. Virtually all Canon andNikon digital cameras have an orientation sensor. The output of this sensor is used to set the EXIF orientation flag in the image file's metatdata to reflect the positioning of the camera with respect to the ground. Canon calls their sensor the "Intelligent Orientation" sensor. It is presumably a 2-axis tilt sensor, allowing 4 possible orientations to be detected. The paragraphs below are taken from that wonderfully illustrated link.
    Auto-rotation in Digital Cameras
    While your digital camera may include an option to "auto-rotate images" due to the camera's orientation, this is almost always just a "virtual rotation". A flag is set to indicate to the viewing software / LCD preview which way to rotate the image before display, rather than rotating the image content itself.
    As lossless image rotation is a fairly compute-intensive operation, digital cameras are not likely to include true lossless rotation after capturing the photo. The CCD/CMOS sensor hardware is designed to stream raw data in a particular direction (e.g. rows then columns), and so it may be hard to incorporate true auto-rotation in-camera without a performance impact to continuous shooting (frames per second).

  • I take pictures and they disappear

    The pictures i take on my iphone are not being saved! When i tap the files symbol it's blank like i never took any pictures. What do i do?

    I just started having the same problem- I snap a picture on my iPhone- it makes the snap sound- recedes to the album in the lower left corner and when I go to the pictures taken in the album- just an outline of the picture is there and it is blank. No NEW photos exist... Additionally, I have tried to restore from iTunes but it did not work or fix the problem rather. Any help would be appreciated. I use the camera feature all of the time and could really use some help. Thanks very much! Joe W.

Maybe you are looking for