Any linux scripting people here?

Associate
Joined
19 Mar 2005
Posts
569
Can anyone help me with writing a script to read the list of names below and then creating a user account for everyone on the list and giving them a home directory and the username the same as there surname?

I am really struggling do i use newuser I dont know how to read in files either, if anyone could help me it would be most appreciated.

Code:
Aird  
Barron 
Chin   
Cunliffe   
Done  
James   
Lynam     
Mountford   
Pelteki     
Revell
Stevenson    
Symonds
 
Hmmm, looks like the command is:

Code:
newusers filename

Where filename contains lines which look like this (with the first entry being all lower-case):

Code:
aird:x:1000:100::/home/Aird:/bin/bash

Check out 'man newusers' and 'man passwd' for more details, or have a look here for some info.
 
Code:
 [font=Arial]#!/bin/sh[/font]

  [font=Arial]echo "Enter the filename of names: "[/font]

  [font=Arial]read file1[/font]

newusers $file1
[font=Arial][/font]

Does this actually work and how do I set the home directory, I am not on a linux machine at the minute so cannot test it. I dont think it is corrrect :mad:. What would be the pseudo code?
 
As cb_linus said, you don't need to write a script really, you can do it with the newusers command. Just create a text file in the format he mentioned then run:

newusers <textfile>

use "man passwd" for more info on that syntax.
 
Back
Top Bottom