I have a question about a bash script:
My Script:
while (( $# )) ; do
case "$1" in
"-ip")
ip="$2"
shift;;
"-port")
port="$2"
shift;;
"-portstep")
portstep="$2"
shift;;
"-maxplayers")
maxplayers="$2"
shift;;
"-password")
password="$2"
shift;;
"-othercommand")
othercommand="$2"
shift;;
esac
shift
done
I run it with:
./script -ip myip -port myport -portstep myportstep -maxplayers mymaxplayers -password mypassword
This is for an gameserver webinterface. I can modify the command like I want.
But now I can set different variables which can be run, and all this commands will set after -password
now I won't set an password I run for example
./script -ip myip -port myport -portstep myportstep -maxplayers mymaxplayers -password -othercomamnd myothercomand
now it will set the password to -othercomand,
how i can modify this script so the password variable will set to "nothing" if nothing is given as password, so my script edit the file correctly with no password and add the othercommand correctly.