LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-10-2003, 08:17 AM   #1
80s
Member
 
Registered: Dec 2002
Location: Pretoria South Africa
Distribution: Mandrake 8.1 & 9 Debian Woody
Posts: 41

Rep: Reputation: 15
Creating users with a script


I need to know how to crate users using a script that will read the list form a comma dilimited file ..

Many thanks
 
Old 01-10-2003, 09:49 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
Well basically you have to ask yourself what your comfortable with. You could probably make a shell script like with bash or even something along the lines of a perl script.

I would suggest reading up on the Bash howto and get familiar with bash scripting ( or any other shell you may prefer ) to get you started.

A google search came up with many results on bash scripting.
 
Old 01-10-2003, 10:00 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Yes, and many thanks for *not* posting an example line...

If it's for some weird reason a file w lines like brittany;billg;ellisonl then ($each will hold the name):
for each in $(cat <file> | tr ";" " "); do <command> <args> $each; done

If it's a file w lines like
brittany;"Weird chick";/home/users/b/brittany
billg;"Luser";/home/billg
ellisonl;"dunno";
you'll have to AND sort out the fields AND subst any missing data.
In example all records need to have equal amount of fields:
cat <file> | while read raw; do
# make array
myArray=( $(echo ${raw} | tr ";" " ") )
#so username is ${myArray[0]}, etc etc.
# example home fscker:
myArray[2]=/home/$(basename ${myArray[2]})
if [ -z "${myArray[2]}" ]; then myArray[2]=/home/${myArray[0]}; fi
<command> <args> -d ${myArray[2]} ${myArray[0]}
done
 
Old 01-13-2003, 01:35 AM   #4
80s
Member
 
Registered: Dec 2002
Location: Pretoria South Africa
Distribution: Mandrake 8.1 & 9 Debian Woody
Posts: 41

Original Poster
Rep: Reputation: 15
EG

I was thinking of.
name;student number

Where student number is the password..

Many Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating new users skvasistha Linux - General 3 11-27-2004 12:02 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
Creating Users [HELP] reddog64 Linux - Newbie 2 04-24-2004 11:34 AM
Creating Users mrsolo Linux - Software 2 12-10-2002 02:39 AM
script for creating multiple users d3funct Programming 1 08-21-2001 06:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration