Discussion Locked

converting email addr to wema standards

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
any ideas on the most painless way to convert existing pop account email addresses in linuxconf that are presently just the users last name -ex. smith@domain to wema standards - ex. firstname.lastname@domain.

5 replies

by pingendorf

Here is something that might be able to help you a small shell script that can read a properly formated /etc/passwd file and parse out the name combo you are looking for. run it with the begining uid of the users you want to process and it will runfrom there out. The file is commented so making it run whatever apps you would like from within it useing the parameters of the username the uid the full name or the converted firstname.lastname should be trivial. Hope it helps ps if the formatingdoesn't take you might want to format is before reading it. It will make things much easier.

---CUT HERE---
#!/bin/sh
for passline in `cat /etc/passwd | sed -e 's/ /|/g'`
do
if test -z $1
then
inputid=0
else
inputid=$1
fi
# just grab the userid from the passworf file to compair.
luid=`echo $passline | sed -e 's/ /|/g' | sed -e 's/:/ /g' | awk {print'$3'}`
if test $luid -ge $inputid then
# get the name from the password file of the user
# first we replace spaces with pipes so we can make sure we are spliting on :
# and awking out only theslot for the users name the replacing the pipe
# with a space

name=`echo $passline | sed -e 's/ /|/g' | sed -e 's/:/ /g' | awk {print'$5'} | sed -e 's/\/.*//g' | sed -e 's/|/ /g'` # getting out the user name is fairly simple as it is the first item in the list.
# just grab the line and whack everything after the first : including the first :

luser=`echo $passline | sed -e 's/:.*//g'`

# just in case there is no name you want the name to be the username.

if test -z name

by brianbarber

I know that this doesn't convert the addresses, but if you were ever to replace or re-build the server, e-smith server and gateway (www.e-smith.org) does this automatically when you create a user.

This discussion is closed to new replies.