Thread: User add script
hi,
made script supposed add users tab delimited text file.
when ran it, users added (or seems) don't show on users , groups. after reboot, says gdm user not exist , user (at time sudoer) no longer sudoers user.
can login in shell, files there.
here script ran:
can guys me? had recover system, need know wrong in script, since singlecode:#!/bin/bash if [$1 == ""]; exit 0; fi while read line ifs="" username=`echo $line | cut -f 1` fname=`echo $line | cut -f 2` lname=`echo $line | cut -f 3` description=`echo $line | cut -f 4` homedir=`echo $line | cut -f 5` loginscript=`echo $line | cut -f 6` profile=`echo $line | cut -f 7` pwdexpire=`echo $line | cut -f 8` pwdnotexpire=`echo $line | cut -f 9` echo "username: $username name: $fname $lname description: $description" sudo useradd -c "$fname $lname" -d "/home/$username" -n -m $username done < $1runs fine.code:useradd -c "aaa" -d "/home/aaa" -n -m aaa
again.
the first line (after hash-bang) wrong @ least. [ command, it's not part of if-syntax, arguments must delimited spaces other command.
parsing file, don't see point in using cut, use built in read command.
not sure why script break added users though. take backup of /etc/passwd, compare /etc/passwd after script has run , see did ...code:#!/bin/bash (($#)) || exit # exit if number of arguments 0 while ifs=$'\t' read -r username fname lname desc homedir etc; useradd -c "$fname $lname" ... done < "$1"
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk User add script
Ubuntu
Comments
Post a Comment