Hey all,
Sorry about the xpost to comp.unix.misc, realized this was a better forum.
I've got a ksh script that sends email to a user informing them of
their new account info. It runs either interactively, prompting for
the required info, or quietly when the appropriate options are given
from the command line. It also generates a password for them.
I'm stumped on how to do two things cleanly.... display a
representation of the message to be sent on screen so the admin can
make sure everything looks ok before actually sending the message, and
second, send a copy of the message to the admin with the password
stripped. The function goes something like this (from memory):
function send_mail
{
mailx -s "${subject} for ${user_id}" -e ${user_email) -c
${admin_email} << end
****** CONFIDENTIAL *******
Your account on ${server} has been assigned the username of
${username}
and the password ${password}. You will be prompted to change this
password
the first time you log in.
If you need assistance, feel free to contact me.
Thank you,
${admin_name}
${admin_email}
end
This works fine. But, I would like to change the function somehow soQuote:} # end of send_mail
that it echos to the screen an approximation of what will be sent via
email so I can check for errors and offer me the opportunity to change
something. Also, since the script generates the password for me, I
need to know what it is so I can set it. Currently it CC's a copy to
me, but this is not good for security reasons, so I'd like it to strip
the password from the CC. If I could figure out part1, part2 would be
easy.
I've got it working the way I want using three separate functions
called verify_mail send_user_mail and send_admin_mail, but it's really
ugly because it's pretty much 3 blocks of almost the same code. I
can't seem to figure out a way to get the here doc ( << end ) to echo
to the screen, which is what I've been trying to do, but I think I'm
on the wrong path. I'd also like to avoid using a tmp file if
possible. Any idas?
Thx,
-krp