I am little bit confused to write a script. This script needs the options like unix commands
i.e.
�S to start process.
�C to check process.
-u : user
-p : password
like.
script should run like this
./script.sh -u username -p ***** -S processname
there may be all the options or not. So I am confused how to write this script ??
My Idea :
I want to read all the argument pass and match with the respected details
like if there is -u used so next should be a username or -S then next should be a process name. But this thing needs lot of checks on the arguments only.
and after that I have to call the "case" in the script if there is any specific option in command line.
Since you are the one writing the script dont accept no agument...and add -h for help...
Can S and C be used together?
how many processes can it "start"?
MODE=""
# Loop until we run out of arguments.
while [ "$#" -gt 0 ]
do
case "$1" in
-p)
shift
MYPASS="$1"
;;
-u)
shift
MYUSER="$1"
;;
-S)
MODE="start"
;;
-C)
MODE="check"
;;
*)
echo "Unknown argument '$1'" >&2
exit 1
;;
esac
# Delete $1 argument, set $1=$2, $2=$3, ...
shift
done
if [ -z "$MODE" ]
then
echo "Must give -S or -C" >&2
exit 1
fi
if [ "$MODE" = "check" ]
then
echo "doing check"
fi
...