1 .TH MHSTORE %manext1% 2015-02-06 "%nmhversion%"
6 mhstore \- store contents of nmh MIME messages into files
29 .RB [ \-auto " | " \-noauto ]
31 .IR always " | " auto " | " suffix " | " ask " | " never ]
32 .RB [ \-verbose " | " \-noverbose ]
37 command allows you to store the contents of a collection of MIME
38 (multi-media) messages into files or other messages.
41 manipulates multi-media messages as specified in RFC 2045 to RFC 2049.
45 will store all the parts of each message.
46 Each part will be stored in a separate file. The header fields of
47 the message are not stored. By using the
52 switches, you may limit and reorder the set of parts to be stored,
53 based on part number and/or content type.
60 to use the specified file as the source message, rather than a message
61 from a folder. If you specify this file as \*(lq-\*(rq, then
63 will accept the source message on the standard input. Note that the
64 file, or input from standard input, should be a validly formatted
65 message, just like any other
69 be in mail drop format (to convert a file in
70 mail drop format to a folder of
75 A part specification consists of a series of numbers separated by
76 dots. For example, in a multipart content containing three parts,
77 these would be named as 1, 2, and 3, respectively. If part 2 was also
78 a multipart content containing two parts, these would be named as 2.1
79 and 2.2, respectively. Note that the
81 switch is effective only for messages containing a multipart content.
82 If a message has some other kind of content, or if the part is itself
83 another multipart content, the
85 switch will not prevent the content from being acted upon.
89 switch can also be used to restrict (or, when used in conjunction with
91 to further restrict) the selection of parts according to content type.
94 switches part will only select the first match from a
95 multipart/alternative, even if there is more than one
96 subpart that matches (one of) the given content type(s).
102 switches alone will cause either to select the part(s) they match.
103 Using them together will select only the part(s) matched by both
104 (sets of) switches. In other words, the result is the intersection,
105 and not the union, of their separate match results.
107 A content specification consists of a content type and a subtype.
108 The initial list of \*(lqstandard\*(rq content types and subtypes can
109 be found in RFC 2046.
111 A list of commonly used contents is briefly reproduced here:
115 .ta \w'application 'u
119 multipart mixed, alternative, digest, parallel
120 message rfc822, external-body
121 application octet-stream, postscript
128 A legal MIME message must contain a subtype specification.
130 To specify a content, regardless of its subtype, just use the name
131 of the content, e.g., \*(lqaudio\*(rq. To specify a specific
132 subtype, separate the two with a slash, e.g., \*(lqaudio/basic\*(rq.
133 Note that regardless of the values given to the
135 switch, a multipart content (of any subtype listed above) is always acted
136 upon. Further note that if the
138 switch is used, and it is desirable to act on a message/external-body
141 switch must be used twice: once for message/external-body and once for
142 the content externally referenced.
146 switch will alter the part-ordering of multipart/alternative MIME sections
147 in order to override the sender-imposed default ordering.
150 switch is functionally most important for
152 but is also implemented in
156 to make common part-numbering possible across all three programs.
159 switches will have the highest priority. This allows the command line
160 switches to override profile entries.
165 for more information on
170 switch will cancel any previous
173 .SS "Storing the Contents"
175 will store the contents of the named messages in
176 \*(lqnative\*(rq (decoded) format. Two things must be determined:
177 the directory in which to store the content, and the filenames.
178 Files are written in the directory given by the
179 \*(lqnmh-storage\*(rq profile entry, e.g.,
185 If this entry isn't present, the current working directory is used.
189 switch is given, its argument is used for the filename to store all
190 of the content, with \*(lq-\*(rq indicating standard output. If the
192 switch is given, then
194 will check if the message contains information indicating the filename
195 that should be used to store the content. This information should be
196 specified as the \*(lqfilename\*(rq attribute in the
197 \*(lqContent-Disposition\*(rq header or as the \*(lqname\*(rq
198 attribute in the \*(lqContent-Type\*(rq header for the content you are
199 storing. For security reasons, this filename will be ignored if it
200 begins with the character '/', '.', '|', or '!', or if it contains the
201 character '%'. We also recommend using a \*(lqnmh-storage\*(rq profile
204 switch setting other than the default of \*(lqalways\*(rq to avoid
205 overwriting existing files.
209 switch is not given (or is being ignored for security reasons) then
211 will look in the user's profile for a \*(lqformatting string\*(rq to
212 determine how the different contents should be stored. First,
214 will look for an entry of the form:
217 mhstore-store-<type>/<subtype>
220 to determine the formatting string. If this isn't found,
222 will look for an entry of the form:
228 to determine the formatting string.
230 If the formatting string starts with a \*(lq+\*(rq character, then
231 content is stored in the named folder. A formatting string consisting
232 solely of a \*(lq+\*(rq character is interpreted to be the current
235 If the formatting string consists solely of a \*(lq-\*(rq character,
236 then the content is sent to the standard output.
238 If the formatting string starts with a '|', then it represents
241 to execute which should ultimately store the content.
242 The content will be passed to the standard input of the command.
243 Before the command is executed,
245 will change to the appropriate directory, and any escapes (given below)
246 in the formatting string will be expanded.
247 The use of the \*(lq%a\*(rq sequence is not recommended because
248 the user has no control over the Content-Type parameter data.
250 Otherwise, the formatting string will represent a pathname in which
251 to store the content. If the formatting string starts with a '/',
252 then the content will be stored in the full path given, else the
253 file name will be relative to the value of \*(lqnmh-storage\*(rq or
254 the current working directory. Any escapes (given below) will be
255 expanded, except for the a-escape. Note that if \*(lqnmh-storage\*(rq
256 is not an absolute path, it will be relative to the folder that
257 contains the message(s).
259 A command or pathname formatting string may contain the following
260 escapes. If the content isn't part of a multipart (of any subtype
261 listed above) content, the p-escapes are ignored.
266 %a Parameters from Content-Type (only valid with command)
267 %m Insert message number
268 %P Insert part number with leading dot
269 %p Insert part number without leading dot
270 %t Insert content type
271 %s Insert content subtype
272 %% Insert character %
276 If no formatting string is found,
278 will check to see if the content is application/octet-stream with parameter
279 \*(lqtype=tar\*(rq. If so,
281 will choose an appropriate filename. If the content is not
282 application/octet-stream, then
284 will check to see if the content is a message. If so,
286 will use the value \*(lq+\*(rq. As a last resort,
288 will use the value \*(lq%m%P.%s\*(rq.
290 Example profile entries might be:
294 mhstore-store-text: %m%P.txt
295 mhstore-store-text: +inbox
296 mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
297 mhstore-store-image/jpeg: %m%P.jpg
298 mhstore-store-application/PostScript: %m%P.ps
306 to print out the names of files that it stores. For backward
307 compatibility, it is the default. The
309 switch suppresses these printouts.
310 .SS "Overwriting Existing Files"
313 switch controls whether
315 should overwrite existing files. The allowed values for this switch
316 and corresponding behavior when
318 encounters an existing file are:
323 always Overwrite existing file (default)
324 auto Create new file of form name-n.extension
325 suffix Create new file of form name.extension.n
326 ask Prompt the user to specify whether or not to overwrite
328 never Do not overwrite existing file
337 is the lowest unused number, starting from one, in the same form. If
338 a filename does not have an extension (following a '.'), then
342 create a new file of the form
352 will be the number of files that were requested but not stored.
356 if standard input is connected to a terminal, the user is prompted to
362 to whether the file should be overwritten. The responses
363 can be abbreviated. If the user responds with
367 prompts the user for the name of the new file to be created. If it is
368 a relative path name (does not begin with '/'), then it is relative to
369 the current directory. If it is an absolute or relative path to a
370 directory that does not exist, the user will be prompted whether to
371 create the directory. If standard input is not connected to a
376 .SS "External Access"
377 For contents of type message/external-body,
378 \fImhstore\fR supports these access-types:
392 For the \*(lqanon-ftp\*(rq and \*(lqftp\*(rq access types,
394 will look for the \*(lqnmh-access-ftp\*(rq
398 nmh-access-ftp: myftp.sh
401 to determine the pathname of a program to perform the FTP retrieval.
402 This program is invoked with these arguments:
406 domain name of FTP-site
412 \*(lqascii\*(rq or \*(lqbinary\*(rq
416 The program should terminate with an exit status of zero if the
417 retrieval is successful, and a non-zero exit status otherwise.
419 For the \*(lqurl\*(rq access types,
421 will look for the \*(lqnmh-access-url\*(rq profile entry, e.g.,
424 nmh-access-url: curl -L
427 to determine the program to use to perform the HTTP retrieval. This program
428 is invoked with one argument: the URL of the content to retrieve. The program
429 should write the content to standard out, and should terminate with a status
430 of zero if the retrieval is successful and a non-zero exit status otherwise.
431 .SS "User Environment"
432 Because the environment in which
434 operates may vary for different machines,
436 will look for the environment variable MHSTORE .
437 If present, this specifies the name of an additional user profile
438 which should be read. Hence, when a user logs in on a particular
439 machine, this environment variable should be set to refer to a
440 file containing definitions useful for that machine. Finally,
442 will attempt to consult
445 %nmhetcdir%/mhn.defaults
448 which is created automatically during
452 See "Profile Lookup" in
454 for the profile search order, and for how duplicate entries are treated.
456 .SS Decoding RFC 2047-encoded file names
457 The improper RFC 2047 encoding of file name parameters can be replaced
458 with correct RFC 2231 encoding using
460 either permanently or ephemerally, e.g.,
464 mhfixmsg -outfile - | mhstore -auto -clobber ask -file -
470 is not necessary, though recommended to avoid silently overwriting an existing
474 looks for additional profile files in multiple locations: absolute
475 pathnames are accessed directly, tilde expansion is done on usernames,
476 and files are searched for in the user's
478 directory as specified in their profile. If not found there, the directory
479 .RI \*(lq %nmhetcdir% \*(rq
484 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
485 ^$HOME/.mh_profile~^The user profile
486 ^$MHSTORE~^Additional profile entries
487 ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
489 .SH "PROFILE COMPONENTS"
493 .ta \w'ExtraBigProfileName 'u
494 ^Path:~^To determine the user's nmh directory
495 ^Current\-Folder:~^To find the default current folder
496 ^nmh-access-ftp:~^Program to retrieve contents via FTP
497 ^nmh-access-url:~^Program to retrieve contents via HTTP
498 ^nmh-storage~^Directory to store contents
499 ^mhstore-store-<type>*~^Template for storing contents
509 .RB ` +folder "' defaults to the current folder"
510 .RB ` msgs "' defaults to cur"
512 .RB ` \-clobber\ always '
516 If a folder is given, it will become the current folder. The last
517 message selected will become the current message.
519 Partial messages contained within a multipart content are not reassembled.