Pack Messages into a File

[previous] [next] [table of contents] [index]

Normally, MH stores one message per file. The packf and packmbox commands "pack" messages into a single file. packf uses MMDF style; packmbox uses UUCP style.

These formats are a good way to package messages for transport to another computer. They also take less filesystem space than standard MH folders do: see the Section Saving Filesystem Space.

MMDF Format: packf

As the Example below shows, messages packed with packf are separated by lines of four CTRLA characters. This is the same way the MMDF transfer agent formats its system mailboxes.

Example: packf file format

% cat -v packedfile

^A^A^A^A
Header: xxx

Header: xxx

    ...
Body...

^A^A^A^A
^A^A^A^A
Header: xxx

Header: xxx

    ...
Body...

^A^A^A^A
Unless you give the -file switch, packf uses a file named msgbox in the current directory. If the file exists, the messages are appended. packf copies all messages in the current folder unless you give a folder and message numbers. So, for example, to copy the first ten messages in your current folder and message 23 from data to the file /tmp/messages:
% packf -file /tmp/messages first:10
% packf -file /tmp/messages 23 +data

UUCP/Sendmail Format: packmbox

For transporting messages between systems or storing them in a file to save space, packf is probably the best choice: it's written in the C language, and it's available on (almost) all MH systems. The packmbox shell script is useful when you need to pack a folder in the same format that many non-MH MUAs expect: the format that UUCP and sendmail use. packmbox is in the MH library directory from version 6.8 and above.

As the next Example shows, messages packed with packmbox are separated by lines starting with From, an address and a date. packmbox gets the address from the Return-Path: header field, if there is one; otherwise it creates an address from the From: field. If any line in the message starts with the string "From " ("From" and a space), packmbox changes the string to >From . There's an empty line added after each message.

Example: packmbox file format

% cat packedfile

From ftpmail@online.ora.com Mon Jan 09 10:55:02 1995
Header: xxx

Header: xxx

    ...
Body...


From ehuser Mon Jan 09 14:17:28 1995
Header: xxx

Header: xxx

    ...
Body...

packmbox is in your system's MH library directory, so you'll probably have to use its absolute pathname. It writes to the standard output, so you'll want to redirect its output to a file. Use the shell's > (right angle bracket) operator to create or overwrite the packed file; the >> operator will append. packmbox copies all messages in the current folder unless you give a folder and message numbers. So, for example, to copy the first ten messages in your current folder and message 23 from data to the file /tmp/messages:
% /path/to/library/packmbox first:10 > /tmp/messages
% /path/to/library/packmbox 23 +data >> /tmp/messages

[Table of Contents] [Index] [Previous: Bursting Messages] [Next: MH Shell on a Mailbox File: msh]


Last change $Date: 1996/06/06 15:12:08 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <jerry@ora.com>

Questions or problems regarding this web site should be directed to Steve Gielda.
Copyright 1999 www.cotse.com.  All rights reserved.
Last modified: Friday April 02, 1999.