Results 1 to 2 of 2
Hey guys
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 ...
- 05-06-2011 #1Just Joined!
- Join Date
- May 2011
- Posts
- 1
Help with Scripting
Hey guys
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?
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 both fnp (to force accounts to set a new password at next login: force new passwd) and sda (to restore the /etc/login.defs values to the account: set default account) to reside in and run from the directory /usr/local/sbin. You will use hard links for the two names, and determine at script execution time whether to force or set the accounts given.
The command line for this script will be one of these 3 forms. Note that your script will support all three, and decide from the command line argument $0 which type of invocation is intended:
1. Prompt for and read in account ids from stdin to be forced or set; detect end-of-file (Control-D) in order to terminate.
fnp
sda
2. Use the arguments supplied as account ids to be forced or set. There is no practical limit to the number of account ids that can be supplied as long as the command line does not exceed the maximum.
fnp list-of-account-ids
sda list-of-account-ids
3. The filename (and optional path, absolute or relative) given is read and each user account id (one per line) is forced or set
fnp -f filename
sda -f filename
Note these restrictions:
The only user who can use this script is root. Reject attempts by any other user to execute it.
An account must be valid. That is, there must be an entry in the password file for each account id to be locked or unlocked. In addition, each account must already have a valid password.
Ensure that each error is logged to stderr and also to the log file /var/log/secure. Each successful fnp must also be recorded in /var/log/secure, marked with a distinctive tag for ease of searching for entries to produce a weekly report (no reporting script is required in this assignment).
Bold part is the main question. I kinda understand the first question but the 2 and 3 im lost.
- 05-06-2011 #2
As far as I can see, these three options concern how the script receives the account name(s) whose passwords are to be altered. All three must work and the script must determine which one to use by the form of the command line.
1) (script name alone). The user is prompted to enter the account names interactively.
2) (script name plus account name list). The user enters the account name(s) after the script name: e.g. fnp joe_bloggs.
3) (script name plus filename). The user supplies the name of an existing file that contains the account names, one per line: e.g. fnp namelistfile."I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote