Pine and binaries

2005/07/04 by Lassi A. Liikkanen

Pine and binaries

Pine is a nice email client for UNIX/Linux systems that can be configured to do amazing things! By default, handling of binary file attachments is a bit complicated. This tip shows how to enable Pine to show Word doc, RTF and Adobe PDF files as text.

Check program availability

First you need to check if your system has the programs that can convert the binary files (pdf, doc or rtf) to plain text. This can be done most easily with locate program. The programs you can use may change over the years, but currently there are only few applications and they are:

  • antiword for Word doc files
  • rtf2text for RTF (the link points to an unofficial source, I was unable to find a proper source at the moment)
  • xpdf for Adobe pdf files
If there are missing programs, install them or ask your system operator to install them. These programs are quite easy to install so you should give it a try even if have not done so earlier! After the programs are found, take a note about their locations.

Setup .mailcap

Mailcap is file format for controlling application behavior according to their MIME format (see http://archive.ncsa.uiuc.edu/SDG/Software/XMosaic/mailcap.html for details). In this case, you want to edit your personal mailcap file ~/.mailcap , found in the root of your home directory, possibly empty at the moment. Load your favorite text editor and add the following lines:

#this is a mailcap comment line
application/MSWORD; /usr/bin/antiword '%s' | less; needsterminal
application/PDF; /usr/bin/pdftotext -nopgbrk '%s' - | less; needsterminal
text/RTF; /usr/bin/rtf2text '%s' | less; needsterminal

# the following setting may be commented out
# I use it as MIME format do sometimes get messed up
application/OCTET-STREAM; /usr/bin/antiword '%s' | less; needsterminal

The configuration file format is explained in the reference above. Basically the file just determines what applications take care of particular MIME formatted files and how they do it. For pdftotext I have overridden the default behavior not to printout page breaks, which mess up the less display.

Use Pine to view docs, pdfs and rtfs

Now the configuration is fine. You must restart Pine if you're already running it. Open a message containing an attachment and select view. Standard behavior of Pine is to check if you want to view it or not. Select Yes and be surprised

Keywords: [computers] , [unix] Document's status: Ok (Document dates explained)

This document created: 2005/06/30
Modified: 2005/07/04
Published: 2005/06/30


This document's permanent URI (linking):
http://iki.fi/lassial/guides/computers/050704-pine_and_binaries

© Lassi A. Liikkanen 2005 - 2016. All rights reserved.
^Top of the Page^

*Change layout:
Printable printable
Large text

Myydään:

@lassial Twitter feed: