Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004

    Unanswered: script for adding a new user

    Hi all;

    I'm receiving great answers from this board.Thanks alot for anyone who replys to my questions.I'm new in unix shell scripting and also having alot of questions

    I have a new one.

    I'm trying to create a little script for the root menu that should be able to add a new user.The system has 4 different groups such as marketing,sales. ..I also have a db file that has

    EmployeeNumber, FirstName, LastName, Location, Department
    ************************************************** *******
    12345, Tiger, Woods, Key West, Marketing
    12341, Flip, Wilson, Los Angeles, Entertainment
    My little script should be able to:
    *Prompt for the name of the data file
    *shoul create user accounts for each user
    *Users will belong to one of: mktg, ent, trade, or mgmt groups, based on the Department field
    *Their usernames will be first_last based on the FirstName and LastName fields.
    *They will all be created with Bash Shell defaults, under /home with the default /etc/skel template files included in their new home directories.
    *Display the records for the new users ONLY from /etc/passwd
    *Return to the menu

    Can anyone let me know where I am suppose to start from?

  2. #2
    Join Date
    Jan 2004
    Bordeaux, France
      Prompt for the name of the data file
    Until data file exists
    For every record of data file
       Determine user name
       Determine user group
       Determine user home directory
       Verify that user doesnt already exist, if exist proceed next record
       Create home directory if not exists
       Create the user, if error proceed next record
       Copy template files from /etc/skel to the home directory
       Search and display user definition from /etc/password
    End For
    You'll need to use (it's just suggestions, it may have several solutions ):

    Loop ... Until : 'while' or 'until'
    Prompt : 'read'
    For every .. End For : 'while' 'IFS' 'read' 'continue'
    Verify user : grep /etc/password
    Verify file or dir : 'test -e' 'test -d'
    Create home dir : 'mkdir'
    Create user : 'adduser' or other system specific command
    Copy template : 'cp'
    Search and display : 'grep'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts