image viewer in Mac OS X

2 views
Skip to first unread message

Thomas Manuel Ortiz

unread,
Jul 14, 2002, 11:22:14 PM7/14/02
to
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/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

Robert Royar

unread,
Jul 15, 2002, 10:50:10 AM7/15/02
to
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 viewhtml.sh):
#!/bin/sh
exec /dillo/bin/dillo $1 2> /dev/null >/dev/null &
and to open Word for OSX documents I use a file named runword.sh:
#!/bin/sh

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.

Allan Streib

unread,
Jul 16, 2002, 5:39:15 PM7/16/02
to
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 Preview.app 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:

#!/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

Warren Jones

unread,
Jul 16, 2002, 6:38:40 PM7/16/02
to
Allan Streib <ast...@indiana.edu> 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

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

> Any ideas?

Mr. Ortiz, may I suggest this website:

http://homepage.mac.com/dcox/

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

Reply all
Reply to author
Forward
0 new messages