Re: [Nmh-workers] Attaching a zip file

2007-02-25 Thread Joel Reicher
> Would some kind and generous person be willing to tell me, given a file name 
> and
> the output of "file -i" applied to that file, how to generate text suitable f
> or
> inclusion in an Email as grist for mime, using some language I understand. Th
> at
> is, English, C, Perl, or Java but not Python.

Just in case the other scripts that people have posted aren't what you want,
something like

---
#!/bin/sh

echo "#`file -b -i $1`; name=\"$1\" $1"
---

might be what you're after.

Cheers,

- Joel


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-18 Thread Norman Shapiro
Would some kind and generous person be willing to tell me, given a file name and
the output of "file -i" applied to that file, how to generate text suitable for
inclusion in an Email as grist for mime, using some language I understand. That
is, English, C, Perl, or Java but not Python.

Thank you very much.

Norman Shapiro
798 Barron Avenue
Palo Alto CA 94306-3109
(650) 565-8215
[EMAIL PROTECTED]


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-13 Thread David Levine
Another easy way to attach files is to use the whatnow
"attach" command included in modern nmh.  It hides the
mhbuild commands.  See the send and whatnow man pages.

"Modern" here means since August 2002, I think, though
support for the attachformat option shown below was added in
February 2006.

To use:

0) Add "-attach X-MH-Attachment" to the send: and whatnow: lines in
   your .mh_profile.  Mine look like:

send: -forward -attach X-MH-Attachment -attachformat 1
whatnow: -attach X-MH-Attachment

   And, add some mhshow-suffix entries for the content types that you
   send, if you don't already have them.  I use these:

 The mhshow-suffix entries are necessary to get the:
 proper application type with -attach X-MH-Attachment:
mhshow-suffix-text/plain: .txt
mhshow-suffix-application/msword: .doc
mhshow-suffix-application/pdf: .pdf
mhshow-suffix-application/PostScript: .ps
mhshow-suffix-application/vnd.ms-excel: .xls
mhshow-suffix-application/vnd.ms-powerpoint: .ppt

1) At the whatnow prompt, enter:

attach /tmp/foobar.zip


Then send as usual.  You won't get a chance to preview the mime
output, but I've gained so much confidence with it that I no
longer feel the need to.

Some tips:

* attach allows shell wild cards.
* ls can be used at the whatnow prompt to look for your files.
* al[ist] can be used at the whatnow prompt to show what
  you've attached.  det[ach] can be used to delete
  attachments.  And if you really want, you can edit the
  message to change attachments, though I reserve that for
  reordering.
* Cc: or Bcc: yourself if you want to see what was sent.

David


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-13 Thread Paul Fox
alexander wrote:
 > > 
 > > i'll attach a script i use for forwarding attachments.  it
 > > handles the common binary types i use, plain files, and mail
 > > messages, based on interpreting its arguments.  it produces the
 > You should really just use file(1) here. It will give you mime-types
 > and sutible descriptions for free, and doesn't rely on file extensions.

huh.  someone added a "-i" option to file(1) sometime in the last
25 years, and they didn't tell me!  :-)

(thanks!)

paul
=-
 paul fox, [EMAIL PROTECTED] (arlington, ma, where it's 41.5 degrees)


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-13 Thread Alexander Botero-Lowry
> --- =_aa0
> Content-Type: text/plain; charset="us-ascii"
> Content-ID: <[EMAIL PROTECTED]>
> 
>  > > To attach a compressed tar file, say, /tmp/foobar.tgz, to an Email, I do
>  > > something like:
>  > > 
>  > > #application/octet-stream; \
>  > > type=tar; x-conversion=gzip; \
>  > > name=foobar.tgz  /tmp/foobar.tgz
>  > > 
>  > > Could somebody take pity on an old man and tell me what I would do to 
> attach 
>  > > a zip file, say. /tmp/foobar.zip, to an Email?
>  > 
>  > I'd just do
>  > 
>  > #application/zip; name="foobar.zip" /tmp/foobar.zip
> 
> i'll attach a script i use for forwarding attachments.  it
> handles the common binary types i use, plain files, and mail
> messages, based on interpreting its arguments.  it produces the
You should really just use file(1) here. It will give you mime-types
and sutible descriptions for free, and doesn't rely on file extensions.

My remime script http://people.freebsd.org/~alexbl/remime uses the libmagic
bindings for pytohn for the same effect. I've also attached it. 

> it's far from perfect, i'm sure, but it saves me trying to remember how
> to compose mhbuild lines by hand.
I imagine a _lot_ of people have scripts like this :)

Alex

#!/usr/bin/env python
import sys, re, os 
import magic

msg = ''

descr_ms = magic.open(magic.MAGIC_NONE)
descr_ms.load()
mime_ms = magic.open(magic.MAGIC_MIME)
mime_ms.load()

for a in open(sys.argv[1]):
	if a.startswith('#remime: '):
		filename = a[9:].strip()
		if os.path.exists(filename):
			a = '#%s; name="%s" <>[ %s ] %s\n' % (mime_ms.file(filename), os.path.basename(filename), descr_ms.file(filename), filename)
		else:
			a = '\n'
	msg += a

msg_file = open(sys.argv[1], 'w')
msg_file.write(msg)
msg_file.close()

os.execvp('mhbuild', ('mhbuild', sys.argv[1]))
___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-13 Thread Paul Fox
 > > To attach a compressed tar file, say, /tmp/foobar.tgz, to an Email, I do
 > > something like:
 > > 
 > > #application/octet-stream; \
 > > type=tar; x-conversion=gzip; \
 > > name=foobar.tgz  /tmp/foobar.tgz
 > > 
 > > Could somebody take pity on an old man and tell me what I would do to 
 > > attach 
 > > a zip file, say. /tmp/foobar.zip, to an Email?
 > 
 > I'd just do
 > 
 > #application/zip; name="foobar.zip" /tmp/foobar.zip

i'll attach a script i use for forwarding attachments.  it
handles the common binary types i use, plain files, and mail
messages, based on interpreting its arguments.  it produces the
mhbuild input text necessary to do the forwarding on its stdout --
so, when composing mail in vi, i can type something like:

:r !forward foobar.zip

or even 

!!forward foobar.zip

for files, or 

!!forward cur-last

to forward messages.

it's far from perfect, i'm sure, but it saves me trying to remember how
to compose mhbuild lines by hand.

paul
=-
 paul fox, [EMAIL PROTECTED] (arlington, ma, where it's 37.9 degrees)



forward
Description: - 
___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


Re: [Nmh-workers] Attaching a zip file

2006-12-11 Thread Joel Reicher
> To attach a compressed tar file, say, /tmp/foobar.tgz, to an Email, I do
> something like:
> 
> #application/octet-stream; \
> type=tar; x-conversion=gzip; \
> name=foobar.tgz  /tmp/foobar.tgz
> 
> Could somebody take pity on an old man and tell me what I would do to attach 
> a
> zip file, say. /tmp/foobar.zip, to an Email?

I'd just do

#application/zip; name="foobar.zip" /tmp/foobar.zip

since application/zip is a registered MIME type...

http://www.iana.org/assignments/media-types/

Cheers,

- Joel


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers


[Nmh-workers] Attaching a zip file

2006-12-11 Thread Norman Shapiro
To attach a compressed tar file, say, /tmp/foobar.tgz, to an Email, I do
something like:

#application/octet-stream; \
type=tar; x-conversion=gzip; \
name=foobar.tgz  /tmp/foobar.tgz

Could somebody take pity on an old man and tell me what I would do to attach a
zip file, say. /tmp/foobar.zip, to an Email?


Norman Shapiro
798 Barron Avenue
Palo Alto CA 94306-3109
(650) 565-8215
[EMAIL PROTECTED]


___
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers