I would like to use Apple's Preview application to view attachments I
receive. When I configure PINE to use the command
open -a /Applications/Preview.app
to view images and use the View command inside a message, Preview launches
but I can't see the image (no file is opened). When I view information
about the attachment, the Display method is given as
"open -a /Applications/Preview.app <datafile>"
which sounds like it should be OK. Any ideas?
Thanks
Tom Ortiz
Thomas M. Ortiz
Purdue University
1077 Ray W. Herrick Laboratories
West Lafayette, IN 47907-1077
FILENAME=$1.doc
cp $1 $FILENAME
sleep 2
open $FILENAME
sleep 4
rm $FILENAME
Pine drops the file extent when it passes a filename to open. PC-Pine
(by the way) appears not to do this.
My solution involves a tiny shell script and the use of the .mailcap
file. My .mailcap file looks like this:
# Attachment mappings for Pine
application/msword; ~/bin/openit %s doc
image/*; ~/bin/openit %s
I have a script called "openit" in my bin directory that takes up
to two parameters. The first is the filename, the second is an
optional filename extension. The script looks like:
#!/bin/sh
filebase=`basename $1`
if [ -z "$2" ]
then
tmpfile=/var/tmp/$filebase.$$
else
tmpfile=/var/tmp/$filebase.$$.$2
fi
cp $1 $tmpfile
/usr/bin/open $tmpfile
What this accomplishes is the following:
- For a Word document, it makes a copy of the file in /var/tmp and
appends a ".doc" extension, so that "open" will know it's a word
doc.
- For an image file, it simply makes a copy of the file.
In both cases, /usr/bin/open is invoked to open the file. Naturally
this is extendable to handle Excel attachments and anything else that
can be distinguished by the attachment content-type string. but the
most common ones I get are images and Word docs so that's all that I
have done.
Note that this never cleans up the files, but I believe that /var/tmp
is cleaned at every reboot. You could also have a cron job that
deletes files that are so many days old.
Allan
> Note that this never cleans up the files, but I believe that /var/tmp
> is cleaned at every reboot. You could also have a cron job that
> deletes files that are so many days old.
I do something very similar, but instead of copying the file
to /var/tmp, I just have the script sleep for 10 seconds after
calling open:
/usr/bin/open "$1"
sleep 10
This gives your application plenty of time to open the file
before pine deletes it. However, it won't add a ".doc"
extension, but I haven't had a problem with Word documents
that don't already have the correct extension.
--------------------------------------------------------------------
Warren Jones | To keep every cog and wheel is the first
Fluke Corporation | precaution of intelligent tinkering.
Everett, Washington, USA | -- Aldo Leopold
> Any ideas?
Mr. Ortiz, may I suggest this website:
Select the "PINE Tricks for Mac OS X" folder, and then pick the file
that says "mimedocumentation.txt".
After you read that file, as an example, here is the Perl script I use
for JPEGs:
#!/usr/bin/perl
$arg=$ARGV[0];
system ("cp $arg /Users/mharris/Documents/PINEToys/viewers/tmp/temp-file.jpg");
system ("open /Users/mharris/Documents/PINEToys/viewers/tmp/temp-file.jpg");
Mike