Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
In the command line I will be given files or words which will be USER ID's or a file of USER ID's. I am to let the user of the script know when any of these individuals log in. I can do it a certain why, which is unacceptable.
I could do this without the getopts command, instead I would just write to files and grep each line (each line would be a user ID) and finger it to see if they are on or not.
My problem is after looking all over for information on getopts, it's not making sense to me. I've been messing around with this exampe:
while getopts ":afz" option;
do
case $option in
a)
echo recieved -a
;;
f)
echo recieved -f
;;
z)
echo recieved -z
;;
*)
echo "invalid option -$OPTARG"
;;
esac
done
- Relevant commands, code, scripts, algorithms:
Mainly getopts is encouraged to be used.
- The attempts at a solution (include all code and scripts):
With the getopts I've been messing with, I realize if I type anything but -a, -f, or -z I will get the *) option which is "invalid option". if I type -z -a or -f, it will of course echo the received thing. My problem is how can I make -a -z -f options to see if file is readable, or to see if the user is a valid userid, or to see if they are even on. Basically, I am obviously not putting 2 and 2 together to see how getopt is handy in this case. I'm assuming if i make -z -a or -f various options like I stated, it ought to work, but honestly, I don't know how to do this, very frustrating.
What I'm asking perhaps, is if I can see an example that is related to my issue, and perhaps an explanation to allow me to complete this.
If I could see how this getopts thing is used for such a case, I'm sure I could do it, because I can do it without getopts!
I've been looking at alternative solutions, but due to scoping issues, I see no other option but to write to a file (which is not allowed for this assignment). and parse the file line by line using finger/grep.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
USML, St. Louis, Unix Programming, actually this link has it all:
//*******/~antognolij/cs2750.html
replace ******* with umsl.edu
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).