My understanding is that getopts won't do what you're trying to do.. you can easily use if..then's after the while..loop to determine if the user has entered the required information.
Firstly, according to the code getopts argument list (:s:dvu:p:n:), -s, -u, -p, and -n take a mandatory argument. In the case statement, the code assigns the value of OPTARG to b and c, even though these options are set to not recieve an argument. As such, these items will never hold a value. It might be better to assign them an arbitrary number, like 1 for true, or something:
while getopts ":s:dvu:p:n:" options; do
case $options in
s ) a=$OPTARG;;
d ) b="1";;
v ) c="1";;
u ) d=$OPTARG;;
p ) e=$OPTARG;;
n ) f=$OPTARG;;
\? ) echo $usage
* ) echo $usage
This will at minimum, provide the script with a way to test for these.
And, as to the required options bit, here's a bit of incomplete sample code to show you how I might go about this:
# test to see if they gave the -s option
if [ "x" == "x$a" ]; then
echo "-s [option] is required"
# now, test for the -u option. if they gave it, the
# -p option must also exist
if [ "x" != "x$d" ]; then
if [ "x" == "x$e" ]; then
echo "-u [option] requires -p [option]"
That should do the job.