Re: extracting sender's name for use in a script?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday, August 7 at 10:42 AM, quoth Peter Scott:
> I use a shell script that invokes enscript in order to facilitate
> printing of received mail, and would like to have available, for
> inserting into the enscript header line, the name (or email address)
> of the sender, in the form displayed by hitting the "@" key (for
> example).
Heh, boy, you just want everything, don't you! ;)
There's no facility within mutt (that I know of) to do fancy
parsing/hand-to-script/etc. like you're talking about. The thing you
probably want to do will probably be a self-contained script that you
pipe the entire undecoded message to and then decode yourself.
For example, with the mess822 package (distributed by DJB - search
google for it), there's a program called 822field that you can use for
extracting headers from an email. So, if you have a macro like this:
macro pager P \
'<enter-command> unset pipe_decode<enter><pipe-message>yourscript<enter>'
Then you can extract headers in your script like so:
#!/bin/sh
message="`cat -`"
sender="`echo "$message" | 822field From`"
recipient="`echo "$message" | 822field To`"
CCrecipients="`echo "$message" | 822field CC`"
subject="`echo "$message" | 822field Subject`"
# etc.
#now print, and all the things you want are in those variables
# (I don't know how to use enscript for this, but let's pretend):
echo "$message" | enscript --header="Message from $sender to $recipient
with the subject $subject"
~Kyle
- --
I'm as fond of my body as anyone, but if I can be 200 with a body of
silicon, I'll take it.
-- Danny Hillis
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFE138/BkIOoMqOI14RAo9eAKDwNsDxrrTVFMls2+KSs0gHUgyqIACg1h7W
hwnK8IRxDgf+I13sDAAP318=
=8G+P
-----END PGP SIGNATURE-----