useradd command script help

From: Trinh, Linh T. [C] (TrinhL@nga.mil)
Date: Tue Mar 16 2004 - 14:20:22 EST


Hi,

I need some help with a script to read text file username.txt then execute
useraddscript to add user. I am having problem to read the file username.txt
as psoftid,userid,last,first,middleinit,company as a line without any space
in between. If I add spaces in between then the script will pick the commas.
I am not good at shell scripting. Please help or recommand what option that
I should use.

Thanks, Linh

username.txt
12345,trinhl,Trinh,Linh,,CSC
12346,nguyenp,Nguyen,Phuong,,OTSUKA
12347,doej,Doe,John,,Lockheed

Useraddscript.sh
#useradd -G psoft -d /export/home/trinhl -s /bin/ksh -c LinhTrinh12345 -m -k
/etc/skel trinhl
#psoftid,userid,last,first,midinit,company
/bin/ksh
psoftid=cat username.txt|awk '{print $1}'
userid=cat username.txt|awk '{print $2}'
last=cat username.txt|awk '{print $3}'
first=cat username.txt|awk '{print $4}'
midinit=cat username.txt|awk '{print $5}'
export psoftid,userid,last,first,midinit
useradd -G psoft -d /export/home/$userid -s /bin/ksh -c
$first$midinit$last$psoftid -m -k /etc/skel $userid
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:28:17 EDT