image viewer in Mac OS X

Skip to first unread message

Thomas Manuel Ortiz

Jul 14, 2002, 11:22:14 PM7/14/02
Hello all

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/

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/ <datafile>"

which sounds like it should be OK. Any ideas?


Tom Ortiz

Thomas M. Ortiz
Purdue University
1077 Ray W. Herrick Laboratories
West Lafayette, IN 47907-1077

Robert Royar

Jul 15, 2002, 10:50:10 AM7/15/02
I haven't had much luck with pine and the mac `open -a' command.
However, you might try writing a shell script to load the program. Here
is how I run a browser for html references (in a file named
exec /dillo/bin/dillo $1 2> /dev/null >/dev/null &
and to open Word for OSX documents I use a file named


sleep 2
sleep 4

Pine drops the file extent when it passes a filename to open. PC-Pine
(by the way) appears not to do this.

Allan Streib

Jul 16, 2002, 5:39:15 PM7/16/02
Pine puts the attached image file in a temporary file, which is
deleted as soon as the "viewer" command completes. In this case, the
viewer is the "open" command, which fires off and then
exits. Pine thinks the viewer is done and deletes the temporary file.
Preview opens normally but finds that the file is deleted so it
displays nothing. Same thing happens with Word attachments, etc.

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:

filebase=`basename $1`
if [ -z "$2" ]

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
- 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.


Warren Jones

Jul 16, 2002, 6:38:40 PM7/16/02
Allan Streib <> writes:

> 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

Mike Harris

Jul 18, 2002, 9:27:56 PM7/18/02
On July 14, 2002, Thomas Manuel Ortiz wrote:

> 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:

system ("cp $arg /Users/mharris/Documents/PINEToys/viewers/tmp/temp-file.jpg");
system ("open /Users/mharris/Documents/PINEToys/viewers/tmp/temp-file.jpg");


Reply all
Reply to author
0 new messages