|
Modify Etc Password File
How to modify /etc/password file and compare the username to the
username in a flat file if it finds it then replace the comments field
in /etc/pasword and populated from a flat file with this string Ex. "C-137h
897 Abu Sassi (HP)".
Solution:
Here is the script:
# cat idmod
#!/usr/bin/ksh
PASSWD=/etc/passwd
MYFILE=/export/home/infile
while read LINE
do
USER=$(echo $LINE|awk '{FS=":";print $1}')
GECOS=$(echo $LINE|awk '{FS=":";print $2}')
printf "%-20s""Modifying $USER"
/usr/bin/grep -nli "^${USER}:" $PASSWD
if [ $? = 0 ]
then
usermod -c $GECOS $USER <<EOF> /dev/null 2>&1
none
none
none
$GECOS
EOF
echo "- Done\n"
else
echo "- Unable to Perform Your Request\n"
fi
done< $MYFILE
#
Have a Unix Problem
Do you have
a UNIX Question?
Unix Books :-
UNIX
Programming, Certification, System Administration, Performance Tuning Reference
Books
Return to : - Unix
System Administration Hints and Tips
(c) www.gotothings.com All material on this site is
Copyright.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
All product names are trademarks of their respective
companies.
The site www.gotothings.com is in no way affiliated
with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.
|