UNIX SHELL PROG. & ELM QUESTIONS
Robert Felps
felps at convex.com
Mon May 13 22:50:11 AEST 1991
In <1991May10.064610.25802 at starnet.uucp> moe at starnet.uucp (Moe S.) writes:
>I appreciate any help on these questions:
>1. If I have a large (500+ messages) in a mailbox-format file,
> what is the best way to mail a file to everyone of the 500+?
> (using elm or any other way).
Sounds like your #2 questions is will answer this. Strip the addresses
out then send the message to them. The problem is the limit of 550+
addresses by most mailers. I'd try writing a script to strip the
addresses put them in a file, split the file, then feed the files
as arguments to ucb/mail with a -s "subject" argument too.
>2. If I have a file containing some names and email addresses such as
> this:
>
> xyz at jkjk.jkyu.reyui (John J. Doe)
> Mark L. Lost <apple!mark at eee.dfsjk.jkj>
> Joe!!! jjj at jhdf.434r.er
> (Such a file can be obtained by doing
> grep "^From:" mailbox_file )
> How can I re-organize the file (using awk, sed, etc...) so that
> the email addresses are the first field in every line in the file?
> Note that all addresses will contain at least one of the two
> characters: "@" or "!".
> Let's say the file is too big to make manual editing practical.
Hmmm. I noticed others posted suggestions of PERL or icon. I don't see
this as much a language question as I do a standard format and the
unexpected non-conformance to that standard. Someone touched on this with
the reference to the RFC. Here's is quick shot that gets a large percentage
of the addresses but it doesn't handle all of the off the wall cases.
for example, I ran it through my $MAIL file and had a blank line in the
output. When I looked at what caused it I had a message with the line,
From: Roger Rabbit is expecting to see you later today.....
from a wonderful secretary that could care less if the mailer uses the
From: header. So those are going to be difficult to message out or catch.
Here's the code, unfortunately it uses nawk because of the Field Separator:
--------------------------------- cut here ----------------------------------
nawk 'BEGIN {
FS="[ ()<>:]" # space, tab, left/right paren, left/rigth angles, colon
}
/^F[rR][oO][mM]:/ {
for ( i = 1; i <= NF; i++ ) {
if ( index($i,"@") ) {
print $i
break
}
else if ( index($i,"!") ) {
print $i
break
}
}
# print "i="i " NF="NF
# print
if ( i > NF )
if ( length($2) )
print $2
else
print $3
}' $MAIL
--------------------------------- cut here ----------------------------------
If you don't have nawk and you don't know awk send me mail and I'll convert
it to awk (old awk).
>Thanks again.
>Moe
Hope it helps,
Robert Felps I do not speak for felps at convex.com
Convex Computer Corp Convex and I seldom Product Specialist
3000 Waterview Parkway speak for myself. Tech. Assistant Ctr
Richardson, Tx. 75080 VMS? What's that? 1(800) 952-0379
More information about the Comp.unix.wizards
mailing list