nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

how to add group of users from an input file

This is a discussion on how to add group of users from an input file within the Shell scripting forums, part of the Development/Scripting category; I am using Fedora 9 linux. I am wondering how can I add a group of users from an input ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 08-05-2008, 08:01 AM
Junior Member
User
 
Join Date: Aug 2008
My distro: Fedora
Posts: 1
Rep Power: 0
john23 is on a distinguished road
Default how to add group of users from an input file

I am using Fedora 9 linux. I am wondering how can I add a group of users from an input file (plan text file) and specify that the script can only be executed by administrator or users with administartors right. I have been trying some codes such as this but im not sure if its right or wrong.

vi file1.sh
cat userlist | while read xyz
do
useradd "$xyz"
done

and then I made vi userlist and added the names such as Tom, sue, pat, Joe in it then ./file1.sh to execute it.

another code is: vi file2.sh
cat $1 | while read username fullname
do
useradd -c "$fullname" "$username"
done
then i created vi userlist4 and added the names such as: Tom Hanks, Joe mason, Jim Joseph. then executed using cat /etc/passwd command.

so i want to know which code is the right one to add a group of users from an input txt file??? If none of the above code is right could you please provide me with a code. thanks.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-06-2008, 02:59 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Linux: How to create multiple users accounts in batch
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Putting multiple users in one group in one shot hrishikesh Shell scripting 2 06-23-2008 08:41 PM
Interpreting ~ from user input al001 Shell scripting 2 04-21-2008 09:27 PM
Add multiple users to a group chuckbeattie Linux software 2 11-03-2007 12:04 AM
curses Problems with Non-Blocking input kgmf Coding in General 3 04-01-2005 02:49 PM
Program gets aborted on large input Ssk Linux software 7 03-14-2005 12:04 PM


All times are GMT +5.5. The time now is 02:49 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36