I am not sure if switch
is the proper terminology as I am new to Unix
.
I have a shell script that requires what I call a switch
to function properly but I also want to pass arguments:
./scriptname -cm
where if I run just ./scriptname
it would fail. But I also want to pass various arguments:
./scriptname -cm arg1 arg2 arg3 arg4
This appears to fail due to the -cm
. Normally when I do ./scriptname arg1 arg2 arg3
it will work properly but once I add the switch it fails. Suggestions?
Edit1:
Adding some more relevant code:
./scriptname -cm
will call
scriptname
gencmlicense()
{
echo $2
do stuff
}
gentermlicense()
{
do stuff
}
if [ "$1" = "-cm" ] ; then
gencmlicense
elif [ "$1" = "-term" ] ; then
gentermlicense
fi
If I added an argument the echo $2
would not print out the second argument passed.