Browse Source

Catching null argument

Error message with suggestion displays
master
Brandon Nolet 2 years ago
parent
commit
7f41a415f0
1 changed files with 21 additions and 29 deletions
  1. +21
    -29
      nmcli-basic.sh

+ 21
- 29
nmcli-basic.sh View File

@@ -4,18 +4,22 @@
# Author/Copyright: Brandon Nolet
# Contact: nolet.brandon@gmail.com

# Description: This is a basic script that makes use
# of the nmcli command, setting either a static or
# dynamic IPv4 address. The script will take one or
# no arguments. Should no arguments be passed to the
# script, then the user will be prompted for the mode
# to set the interface to. Otherwise the syntax is as follows
#
# Syntax:
# ./nmcli-basic.sh [dynamic|static]
#
# The script will also take automatic, auto, and dhcp
# as valid dynamic address inputs.
function usage() {
echo "
Description: This is a basic script that makes use
of the nmcli command, setting either a static or
dynamic IPv4 address. The script will take one or
no arguments. Should no arguments be passed to the
script, then the user will be prompted for the mode
to set the interface to. Otherwise the syntax is as follows

Syntax:
./nmcli-basic.sh [dynamic|static|usage]

The script will also take automatic, auto, and dhcp
as valid inputs for dynamic addressing.
"
}

NMCLI_BIN=$(which nmcli)

@@ -65,23 +69,6 @@ function conshow() {
echo
}

function usage() {
echo "
Description: This is a basic script that makes use
of the nmcli command, setting either a static or
dynamic IPv4 address. The script will take one or
no arguments. Should no arguments be passed to the
script, then the user will be prompted for the mode
to set the interface to. Otherwise the syntax is as follows

Syntax:
./nmcli-basic.sh [dynamic|static]

The script will also take automatic, auto, and dhcp
as valid inputs for dynamic addressing.
"
}

case "$1" in
[dD]ynamic | [aA]uto | [aA]utomatic | [dD][hH][cC][pP])
conshow
@@ -105,6 +92,11 @@ case "$1" in
setstatic
;;
esac
;;
*)
echo "Sorry, argument '${1}' not understood."
echo "Try passing 'usage' instead"

esac

exit 0


Loading…
Cancel
Save