Results 1 to 2 of 2
Im new to the forums. I know you guys probably get a whole bunch of guys asking to do there homework and i'm sorry to have to be one of ...
- 11-20-2011 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 1
Help with scripting
Im new to the forums. I know you guys probably get a whole bunch of guys asking to do there homework and i'm sorry to have to be one of them.
I don't need you guys to do it for me but i just can't understand the question. Can someone translate this question so i can understand what i'm supposed to do?
Please I really need help, I've been searching for hours I can seem to get what my prof wants. Thanks
----------------------
There will be a single script used as the CLI tool (note: you may choose to build the solution as several scripts or functions to minimize duplicate code, but the user will only operate with one apparent script) named lock (to lock accounts) with a hard link with the name unlock (to unlock accounts). Both entries will reside in and run from the directory /usr/local/sbin.
The command line for this script will support all of these three forms:
1. Prompt for and read in any number of account ids from stdin (one per line) to be locked or unlocked; detect end-of-file (Control-D) in order to terminate the script. This is the no arguments case.
lock
unlock
Example:
xxx# lock
Enter Account: user123
Enter Account: ^D
Accounts user123 locked
xxx#
2. The filename (and optional path, absolute or relative) given is read and each user account id (one per line) is locked or unlocked. This is the exactly 2 arguments case.
lock -f filename
unlock -f filename
Example:
xxx# lock -f accounts.text
Accounts user567 user678 locked
xxx#
where accounts.text is:
user567
user678
3. Use any number of arguments supplied as account ids to be locked or unlocked. There is no practical limit to the number of account ids that can be supplied as long as the command line does not exceed 256 characters total. This case has at least 1 argument.
lock list-of-account-ids
unlock list-of-account-ids
Example:
xxx# unlock user123 user234 user345 user456
Accounts user123 user234 user345 user456 unlocked
xxx#
Note these restrictions:
The only user who can use this script is root. Reject any attempt by any other user to execute it.
An account must be valid. That is, there must be a valid entry in the password file for each account id to be locked or unlocked.
The account must not already be locked (for lock) or must already be locked (for unlock) prior to the script's action.
Each account must have a valid password.
Ensure that each error is logged to stderr and also to the log file /var/log/acct-lock. Each successful lock or unlock must also be recorded in /var/log/acct-lock, each entry marked with a distinctive tag for ease of searching for entries (locked OK, unlocked OK, locked error, unlocked error, etc.) suitable for the production of a weekly report (no reporting script is required in this assignment).
- 11-21-2011 #2
Homework questions are not allowed on this forum, so I am going to lock this thread. If you are having difficulty understanding the assignment, I encourage you to contact your professor.
DISTRO=Arch
Registered Linux User #388732


