I'm trying to write a script to add users non-interactively
The script should read the names of the users (each on a line by themselves) from STDIN
It should set the password (to the user’s name), ensure directory creation, and lock the account after creation. Your script should check to see if the user already exists and NOT attempt to add the user if the user exists by using `cat /etc/passwd | grep $username` to check and see if empty should run like: cat /root/users | ./addusers.bsh I've been stuck on this for a while, can anyone help me out? |
Quote:
Quote:
Quote:
Quote:
Anyway, show us what you have tried so far. I doubt anybody here will write a script for you from scratch for free. |
Step 1) Ignore the script part of this assignment. How do you create a user, create its home directory, set its password, and lock it on the command line? Once you know what commands you need, stick them in a file and call it a script. That's all a script is, a sequence of standard commands you type on the command line. Once you know the commands, creating a script is nothing more than copying and pasting them into a text file.
Step 2) Add input parsing. How do you read a file to get the user names? Add it to your script and wrap your above commands inside a loop over these user names. Step 3) Add error checking. How do you check if a user already exists? Add it to your script. If you run into a problem, ask, but it needs to be a specific problem, not the entire assignment verbatim. |
All times are GMT -5. The time now is 11:48 AM. |