From: akabou on 14 Feb 2010 13:00 Hello, i have a problem with my script, i read a file csv with firstname, lastname, group and i must check if group exist, if not i mus create it. and then create user and give him group. liste="liste_etudiants.csv" cat $liste| while read users; do l1prenom="$(echo $users | cut -c2 | tr -d '"')" nom="$(echo $users | cut -d, -f2 | tr -d '"')" group="$(echo $users | cut -d, -f3 | tr -d '"')" echo "$group" login="$l1prenom$nom" pwd=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 10); /usr/bin/id -g $group 2>/dev/null if [ $? -eq 0 ]; then echo "Le Groupe existe on va cree le user." /usr/bin/id $login 2>/dev/null if [ $? -eq 0 ]; then echo "User trouve" exit 1 else #create user and apply group useradd -md /home/ $login -g $group -p $pwd $login fi else #create group groupadd $group; #creat user echo "useradd -md /home/ $login -g $group -p $pwd $login" fi done here is the back of the script when i apply it. L1 is not a valid group name -p AZSrMjZM94 pmartinrtin -g L1 L2 is not a valid group name -p 9jsnLs8PyH felkouhenuhen -g L2 L1 is not a valid group name -p w6Vw6LwNEa fgeorgesrges -g L1 L1 is not a valid group name -p 95MVvcHstK stebibebib -g L1 L2 is not a valid group name -p G4W0OjfPTg nduvallierlier -g L2 L2 is not a valid group name -p qyDEhgCqBP smartinrtin -g L2 L2 is not a valid group name -p WwrBZ4jF7g pmartinrtin -g L2 i don't understand why groupadd L2 is not ok. Thanks for your answers
From: Bill Marcum on 14 Feb 2010 19:23 On 2010-02-14, akabou <dvdmonster.fr(a)gmail.com> wrote: > > here is the back of the script when i apply it. > > L1 > is not a valid group name > -p AZSrMjZM94 pmartinrtin -g L1 I think your file was created on a Windoze system, and each line ends with a CR character, which your script tries to use as part of the group name.
From: akabou on 22 Feb 2010 14:26 On 15 fév, 01:23, Bill Marcum <marcumb...(a)bellsouth.net> wrote: > On 2010-02-14, akabou <dvdmonster...(a)gmail.com> wrote: > > > > > here is the back of the script when i apply it. > > > L1 > > is not a valid group name > > -p AZSrMjZM94 pmartinrtin -g L1 > > I think your file was created on a Windoze system, and each line ends > with a CR character, which your script tries to use as part of the group > name. Thanks for you answer i've solved the problem
|
Pages: 1 Prev: Comm V/s XML data Next: Work at Home- Earn $4,000 Weekly With Email Reading Jobs |