Register
It is currently Wed Aug 20, 2014 10:20 pm

script for generating users


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Tue Nov 18, 2008 11:19 am   

Joined: Tue Nov 18, 2008 11:12 am
Posts: 2
Hi,

I am doing a script that takes users from a file and creates the users, but I am having problems with useradd, I do:
cat faux | while read line; do
dni=u`echo $line|cut -f1 -d,`
cognom1=`echo $line|cut -f2 -d,`
cognom2=`echo $line|cut -f3 -d,`
nom=`echo $line|cut -f4 -d,`
ciutat=`echo $line|cut -f5 -d,`
comment=\'`echo $nom $cognom1 $cognom2, $ciutat`\'


and to create the user:
adduser --gid $gid --gecos $comment --disabled-password $dni

but adduser returns:
adduser: Only one or two names allowed.

If i removed the gecos information i get rid of the problem but I have to insert the information manually and i want to do it automatically.

Any suggestions??

Thank you very much!


Top
 Profile  
 PostPosted: Tue Nov 18, 2008 11:23 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Try to encase $comment in "".
might be that it tries to add a "another" user because your comment contains a whitespace character.

Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Tue Nov 18, 2008 11:25 am   

Joined: Tue Nov 18, 2008 11:12 am
Posts: 2
fredrik.eriksson wrote:
Try to encase $comment in "".
might be that it tries to add a "another" user because your comment contains a whitespace character.

Best regards
Fredrik Eriksson

Mmm that worked!! thanks!!
I tried before doing comment="`echo $nom $cognom1 $cognom2, $ciutat`" but it didnt work.
Thank you very much!


Last edited by electrostatico on Tue Nov 18, 2008 11:29 am, edited 2 times in total.

Top
 Profile  
 PostPosted: Tue Nov 18, 2008 11:26 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Then try to echo $comment and see what it actually contains, if it works without --gecos it's probably doing something fishy.

Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Fri Nov 21, 2008 5:18 pm   

Joined: Thu Oct 16, 2008 3:05 pm
Posts: 13
Try using the script posted here:
http://bashscripts.org/viewtopic.php?t=603&highlight=

and see if that would help you.

:-)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP