nixCraft Linux Forum

nixCraft

Linux / UNIX 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 ...

Register free or login to your existing account and remove all advertisements.


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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2008, 08:01 AM
Junior Member
User
 
Join Date: Aug 2008
OS: Fedora
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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
  #2 (permalink)  
Old 08-06-2008, 02:59 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,662
Thanks: 11
Thanked 237 Times in 177 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


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 Off


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 06:04 AM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

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 37 38