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

A set of scripts to create email links to movies Internet
Last week I showed my wonderful wife how to use Image Capture to copy movies from our camera onto the eMac. The next day she tried to email six movies of the kids to grandpa totaling around 80 MBs ... three times ... it did not work. So I thought I would help her out and wrote a droplet that lets her 'email' the movie clips. That is, it uploads the movies to a web server, then emails the links to the movies instead of the movies themselves.

Copy and paste this AppleScript into Script Editor and save as an Application. I named it 'Mail Link' and saved it into the /Applications folder. Then copy and paste this shell script into a text editor. Change the server=example.com and user=foo lines to match your server account settings. Save it as maillink into /usr/local/bin, and make it executable. Note that you cannot change this name or location without modifying the AppleScript -- the end of this hint also contains a link to an archive of everything you need, with instructions on how to install.

What this script does is it takes the file(s) you wish to email as command line arguments. It then guesses what the file types are and opens Mail.app with a new message containing link(s) to the soon-to-be-uploaded files. Then it uses scp to copy them to a web server. (You need to have an account somewhere.) You could change the last command to cp if you run a web server on your machine, and disable the BatchMode if you do not share keys with your web server. If you would like to share keys so that you do not need to enter passwords, read this article at O'Reilly about how to do it. If you want password-protected keys, look in to ssh-agent and one of either SSH Agent or SSHKeychain. Just as a meta hint, if you need to use ftp to transfer files to your webserver, curl is your friend. That way, you will not need to hard-code a password into your script. Just use the -u and -T options in the curl -- see the man curl page for more info.

This script surprised me because I actually end-up using it myself -- I just type a maillink command from the Terminal whenever I want to send something from my iBook now. For my wife, I dragged the Mail Link AppleScript application to her dock, right next to the Image Capture icon. Now she just drags the movie clips she likes from the Finder onto the Mail Link icon in the dock, composes the mail message, and sends it.

The AppleScript fires-off the maillink shell script inside of Terminal.app instead of with a do shell call, because that way you can watch the progress of your upload and whether the upload succeded or not after you compose your message. It was an old hint I used from this very site that showed me how to make a droplet :). I looked at the 'Crazy Message Text' AppleScript from Mail.app to see how to create a new message.

Here is a 4KB arhive that contains the the scripts, and a script that you can run to install it on your machine. I would have used a Makefile and install, but I think that they come with the Developer Tools. Extract the archive by double-clicking on it if you need to, open the maillink folder that was created in the Finder, and double-click on the maillink.txt file it contains. This will open it in TextEdit, so that you can change the two lines for your server and username, and save the changes. Finally open a Terminal window, cd into the maillink folder, and type this command:
sudo /bin/sh ./install.sh
That should install the AppleScript and shell script in the right places. You will have to drag the Mail Link droplet to your dock, Desktop, or wherever you want it after that.

This droplet has another useful purpose for my wife. Sometimes her father wants to print some picture of a grandchild. He wants a high-res version for that, which would be multi-megabytes in size. My wife can just drag the picture from the index view of iPhoto onto the droplet for that. She discovered this usefulness all by herself, I am so proud of her cleverness. So I added recognition for audio and image files to the shell script. It is only a matter of time until she will want to send some cute thing the kids say in an email message!
    •    
  • Currently 2.25 / 5
  You rated: 2 / 5 (4 votes cast)
 
[7,228 views]  

A set of scripts to create email links to movies | 3 comments | Create New Account
Click here to return to the 'A set of scripts to create email links to movies' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A set of scripts to create email links to movies
Authored by: rkleim on May 28, '05 10:43:01AM

Well, the archive link doesn't work (and is misspelled), when I install myself I get the following, which makes me wonder just what is going on. Avoid installing this until someone more knowledgeable than I looks over it. The poster seems somewhat careless in the details, which doesn't bode well for what this does. I have changed some items in this list to protect the innocent:

/usr/local/bin/maillink '/Volumes/Mac160FULL/Pictures/Digital Camera Photos/Raw pix in from camera/Raw Movies/MVI_0013.AVI' && exit || kill `ps $$ -o [iMac17:~] mymacid% /usr/local/bin/maillink '/Volumes/Mac160FULL/Pictures/Digital Camera Photos/Raw pix in from camera/Raw Movies/MVI_0013.AVI' && exit || kill `ps $$ -o ppid=`
214:215: syntax error: Expected expression but found unknown token. (-2741)
reverse mapping checking getaddrinfo for 245.67-19-75.reverse.theplanet.com failed - POSSIBLE BREAKIN ATTEMPT!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for myaddress.com has changed,
and the key for the according IP address 67.XX.XX.XX
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
a7:b3:DELETED.
Please contact your system administrator.
Add correct host key in /Users/mymacid/.ssh/known_hosts to get rid of this message.
Offending key in /Users/mymacid/.ssh/known_hosts:2
RSA host key for myaddress.com has changed and you have requested strict checking.
Host key verification failed.
lost connection
[iMac17:~] mymacid% [Process was terminated by signal 15]



[ Reply to This | # ]
A set of scripts to create email links to movies
Authored by: mzs on May 29, '05 08:05:49AM
/usr/local/bin/maillink '/Volumes/Mac160FULL/Pictures/Digital Camera Photos/Raw pix in from camera/Raw Movies/MVI_0013.AVI' && exit || kill `ps $$ -o[iMac17:~] mymacid% /usr/local/bin/maillink '/Volumes/Mac160FULL/Pictures/Digital Camera Photos/Raw pix in from camera/Raw Movies/MVI_0013.AVI' && exit || kill `ps $$ -o ppid=
I don't know for sure what that is about. Did you use the install.sh script or copy and paste things into editors? My hunch is that this part of a line in the applescript got munged:
 && exit || kill `ps $$ -o ppid=`"
You could run the maillink script from the command line to see if my hunch is right and that error disappears. The comment above that line explains what the point of that line is. Another possibility is that the continuation characters in the maillink bourne shell script got munged. Those are there in the little snippet of apple script that opens Mail.app with a new message.

As to the error that scared you more it seems, there are two things to that. First you may have your dns not configured properly as scp is failing with that early on. If you have 10.4.x (I don't) I think there was a hint about that on this site relating to ssh. The other bit about that, well I have the option -o 'StrictHostKeyChecking yes' with the scp command. It is supposed to do this very thing if the keys have changed. I did this precisely so my wife would get scared and ask me for help if that happened. This can happen for completely innocent reasons, say for example someone reinstalls a system and does not backup the old keys.

I hope this alleviates your concerns.

[ Reply to This | # ]

A little knowledge still goes a long way
Authored by: Lectrick on May 30, '05 12:54:48AM
Or, you could just use YouSendIt =)

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]