Murphy Mac - Screencasts and Tutorials » Page 'Retrieve a Remote File – by Email '

Retrieve a Remote File – by Email

Share

zipIf you’re using an iPhone or a touch or some other mobile device this could be a very convenient way to retrieve a file from home and view it on your device.

Here’s the scenario: You’re on the bus, you realize your French homework is sitting at home on your Mac. Send yourself a text message with the path to the file. By the time you get to school and log on to a computer your file has been emailed. Problem solved.

Configure Murphy’s script to run every so often using something like launchd. Then send yourself an email. Include the path to the file you want sent in the body, like this:

/Users/murphy/Documents/PenskeFile.doc.

Mail will create a new message, attach the file, and send it to the address in the script. You can configure the script to run when a certain word is in the email subject, like FileGrab. This is an ideal use for rules in Mail.app. But rules don’t seem to work in Mail as of 10.5.1. Murphy hasn’t tried 10.5.2 yet.

Update:  If you leave the file name out the folder’s contents will be zipped and sent.

Instead of using rules, this script is written to run periodically. Maybe every ten minutes or so. If it sees an email with the keyword in the subject it checks for the file and sends it. If the file doesn’t exist the script sends an email that says so.

zip

Security hole? Well, Murphy doesn’t think so. The file will only be mailed to the address you specify in the script, it’s not a reply. (you could alter the script to have it reply, but that doesn’t seem like a good idea.) You can use secure email to send the request and the file. That’s secure.

Getting back to the mobile devices: Your unhacked iPhone and touch don’t let you download files. So you can’t SSH back to the house and grab the file. You could set up your Mac as a web server, but I wouldn’t want to do that.

Using this script the file is emailed to you, so you can view it in Mobile Mail or Gmail depending on what kind of file it is. You can easily view the file later, when you’re offline. The catch? You need to know the path to the file you’re retrieving. Don’t know the path? Here’s some help.

Windows Users: Have a look here.

Note: Script requires use of Mail.app. To schedule this script to run on a schedule you might want to try something like lingon for editing your launchd configuration.

Other Murphy scripts for working with Mail:

Sleep Your Mac by Email

Select a Playlist by Email

Get a List of Your Files by Email

Retrieve Mail.app Messages by Text Message (this post shows how to match emails with Applescript using multiple criteria)


Download Script | Permalink

28 comments to “Retrieve a Remote File – by Email”

  1. Murphy, why macbooks have only one mouse button? And what is the advantage anyway? I think its annoying.

    Sometimes I think its best an alienware with Ubuntu than a Macbook, but Macbooks are so attractive… Im having a hard time deciding, because I want to get away from windows.

    Best regards.

  2. Hi Caio
    That question has sparked many angry discussions all over the Internet. It’s not really an issue these days. OSX has full support for right-clicking, even on laptops with only one mouse button.

    If you have an iMac or Mac Pro you can buy a mouse with as many buttons as you’d like to have. Just make sure the mouse works with OS X. Same for the Mini, which doesn’t come with a mouse.

    Before I bought my first Mac laptop I wondered if the one mouse button would be a problem. It’s not. At this point I think the one large button makes better ergonomic sense. With two fingers on the pad a button press is a right click. Or you can just tap two fingers on the pad.

    There are other features too, like two-finger dragging to scroll.

    Apple’s stance on this might seem annoying, I agree. But like I said, I really like the one large button that can be used for right or left click, and I’d have a hard time giving it up at this point.

    Note: Murphy has a feed for comments.

  3. Well, that makes sense now. We have to consider it is a more advanced touchpad. Maybe it is ergonomics.

    I thought Steve was just too stubborn with that “stay hungry, stay foolish” to split the button in half but, hey, the mighty mouse has a lot of configurable buttons, and I guess one-button mouse is not a mac icon like the apple and finder icons.

    Well, I just hope so, because Im going mac now :)

    Best regards.

  4. I’ve switched from XP to OS X 3 months ago and continue to use the same multi-buttons logitech mouse : it has worked plug & play, I’ve installed nothing.

    I’ve configured the 3th button for the Dashboard (= F12), the 4th button for Space (= F8) and the 5th for Expose (= F9). I have another button available (the 6th) but did not succeed in configuring it. To be noticed that the horizontal scrolling offered by this mouse (with the wheel) works on OS X when it did not on XP.

  5. I’ve given this a go, modified the To and From email addresses.
    It works only if I have ScriptEditor active and Run the file.
    Also, I can only get it to pull a sample file from the Desktop. Making the request from the same sample file in the Documents folder generates the No Such File response.

  6. Jim -

    You have to schedule the script to run periodically. I would suggest using something like lingon (mentioned in the post above.)

    Or you could schedule it to run with iCal if you prefer.

    As an alternative, the script could be set to run with a rule in Mail.app – see the preferences for details. Or see the post linked above, sleep your mac by email for a screencast on rules in mail.app.

    As for the file it’s not working with: Make sure your path is correct. A path is case sensitive on a Mac. I tested with files places throughout my home folder.

  7. are you a seinfeld fan?

    penske file

  8. stefan – You do know that Penske is interested in Murphy…

  9. Great idea murphy.
    Taking cue from ur idea only, I made an outlook macro
    that windows users can use for the same effect at shantanugoel.com
    once again, i’d like to commend you abt it, because ideas are what matter the most..

  10. Thanks Shantanu. Nice work.

  11. I want to have the script look in a specified folder on my laptop (example users/”username”/documents/tograb) and cross reference a name from the body of my email. That way I can just type in the document name in my email and forgo the path. Any ideas on what changes i need to make in the script I’ve tried a few things but as of yet nogo.

  12. I’ll take a look when I get a minute Gregg, but I think you should be able to hold the path in a variable and concatenate it with the file name captured from the email in a second variable.

  13. This is great. I set it up with launchd as suggested. How do you make it stop. If it runs every hour. It attempts it every hour until the request email is deleted. Am I missing something?

  14. The script is supposed to delete the email immediately. Look at the top of the script. It deletes the message from the inbox and then from the trash.

    I was seeing some weird Mail behavior where it seemed like Mail still thought the email was there. Then it would suddenly realize it was gone after running the script a couple times. I think it’s a Mail.app quirk where it’s caching the deleted message somewhere.

    Do you think that’s what’s happening to you?

  15. Applescript rules still don’t work with Mail.app in 10.5.2 as far as I can tell.

    A side note (and this may be obvious but …).
    I tried this command using just the path: /Users/username/Desktop and I was emailed a .zip file with all the files on my desktop. Nice.

    This method seems to work with any folders. Useful if you know the folder but not the exact file – particularly with a folder full of small files (text, Word, Excel etc.).

    Fortunately, I keep very little on my desktop, so it didn’t choke my email.

    I don’t show hard disks or servers on the desktop, but if they are shown, I presume these aren’t considered part of the desktop directory, or are they?
    If so, that could cause some crazy recursion issues: “you want the desktop, which is inside the Macintosh HD, which is on the desktop, which is inside the Macintosh HD …”

  16. Andrew – that’s an interesting find. I’ll have to try that out. I’ll have to work that nugget into a post somewhere…thanks for the comment.

    I would hope the drives on your desktop are ignored.

    I’m going to post another mail-related script today or tomorrow. While playing with rules, I found that a script that just flagged messages worked, but a script that created a new mail message did not. I’m still skirting the issue by making my own rule process within the script and having launchd check for applicable mail messages by running the script every so often.

  17. Not to brag, but I setup something very similar to this in the early ’90s… maybe 91 or so under DOS using WordPerfect’s shell scripting and WP Office email system. The shell script will literally scrape the text screen from the mail application looking for new mail, read the subject line and then respond to the various commands.

    Not very stable, but it worked.

  18. awe, “PenskeFile” -> classic…

  19. It’s a little convoluted, but I found a workaround that doesn’t require you to run the script with Launchd.

    Make an application in Automator that will run Applescript, and paste the code from the original mail_requested_file script.
    (For testing, I also had it show a Growl notification)

    Manually make a script that will run that application (like in the sleeper screencast)

    Set the Mail rule to run the script you created. That script will launch the application, while will run the original script.

    I’ve tested this and it works on 10.5.2!

  20. That’s a nice solution David. Not that convoluted either!

  21. Is there a way to get simple applescript apps to no ask for permission before running?

    (apart from putting it into automator)

    Thanks!

  22. This is great. I set it up with launchd as suggested. How do you make it stop. If it runs every hour.

  23. this is good article.. but i never use mac on my home .. next time i will try to use mac thank you for you best article

  24. Great Article, Thanks.

  25. Hi thanks for the script I’ve been looking for something like this for a while, I remember a friend years ago under OS8 or 9 had a script that would do this very same thing!
    I’ve been trying to get a rule to automate the execution and have found some information that might be useful both on other websites and in apples help menu for mail, apple states:
    “When Mail invokes an AppleScript script as a rule action, it looks for a handler named “perform mail action with messages,” which receives a list of messages as its direct object, with an optional parameter that specifies the rule being executed. After you have the rule object and the list of messages, you can access all of the properties that are shown in the Mail AppleScript dictionary for these objects.”

    From what I gather you need this to make it work as an action, I’ve seen other similar takes on it from other sites, but as I’m no applescript guru I’ve still not been able to get it to work, but I wondered if it made sense to you and if and if you might revise your script!

    Thanks

  26. Hi thanks for the script I’ve been looking for something like this for a while, I remember a friend years ago under OS8 or 9 had a script that would do this very same thing!
    I’ve been trying to get a rule to automate the execution and have found some information that might be useful both on other websites and in apples help menu for mail, apple states:
    “When Mail invokes an AppleScript script as a rule action, it looks for a handler named “perform mail action with messages,” which receives a list of messages as its direct object, with an optional parameter that specifies the rule being executed. After you have the rule object and the list of messages, you can access all of the properties that are shown in the Mail AppleScript dictionary for these objects.”

    From what I gather you need this to make it work as an action, I’ve seen other similar takes on it from other sites, but as I’m no applescript guru I’ve still not been able to get it to work, but I wondered if it made sense to you and if and if you might revise your script!

    Thanks

  27. HI,
    This article was very useful for me,for my project description…. I can identify my project concept thanking you……. to all ur team

  28. A nice alternative to this is ControlByMail at http://www.vic2pc.com, which gives you real thorough remote control of your home PC by email. Send yourself files, view websites (like Facebook) at school or work, etc.

Leave a comment