Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing content of a 1 line file and to another prog w/i awk

Status
Not open for further replies.

TripsDad

Technical User
Nov 9, 2007
3
US
Here's the long of it.

I need to send an e-mail notification to a physician when one of her patients is seen in the ER. I get a report at midnight that I parse into however many e-mails, while creating an email address in a separate corresponding however many one line files.

What I can't get my head around is how would I read that one line file which only contains an internal e-mail address (due to HIPAA constraints) into an awk script which would then use an smtp server to deliver the e-mail(s) to another internal smtp server for delivery. I'm doing it this way because I have various network constraints.

Filenames of the email addresses: emailaa, emailab, emailac, etc.
Filenames of the email content:emcontentaa, emcontentab, emcontentac, etc.

As an example: emailaa would contain jsmithmd@emailaddr.org
emcontent would contain an already formatted email message.

I need the program to read emailaa, convert it to a variable, then call an smtp program to send the formatted message to jsmithmd@emailaddr.org, then continue until all messages have been sent.

Any takers? - Thanks, Pat
 
I've gotten this as a concept:

BEGIN { print "Email Addresses: "
while ( (getline name < "addfile" > 0)
print "/usr/bin/sendmail " name " < message01
}

The printed result is:

Email Addresses:
/usr/bin/sendmail doctor01@emailaddr.org < message01
/usr/bin/sendmail doctor02@emailaddr.org < message01
/usr/bin/sendmail doctor03@emailaddr.org < message01

The "message01" is actually a filename with the appropriate email ready to send, as are "message02" and "message03" etc. I have to get the program to do the following:

Email Addresses:
/usr/bin/sendmail doctor01@emailaddr.org < message01
/usr/bin/sendmail doctor02@emailaddr.org < message02
/usr/bin/sendmail doctor03@emailaddr.org < message03

There is probably a very much more elegant way to do this, but I can't seem to see the forest for the trees.

Thanks,

Pat
 
Replace this:
print "/usr/bin/sendmail " name " < message01
with this:
printf "/usr/bin/sendmail %s < message%02d\n", name, ++m

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That was just what I needed.

Thanks!!!

Pat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top