From f5cdd6555a5e6d81fa8981ab39b5e918a5a0b58b Mon Sep 17 00:00:00 2001 From: Michael Rasmussen Date: Sun, 2 Apr 2017 22:16:33 +0000 Subject: [PATCH] Add checks. Fix some bugs --- netconf | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/netconf b/netconf index 07bf060..a4811ca 100644 --- a/netconf +++ b/netconf @@ -153,8 +153,8 @@ def parse_input(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], - 'ha:g:i:m:n', ['help', 'address=', 'gateway=', - 'interface=', 'netmask=', 'nameserver=']) + 'ha:g:i:m:n:', ['help', 'address=', 'gateway=', + 'interface=', 'netmask=', 'nameserver=']) except getopt.GetoptError as err: print str(err) usage() @@ -207,7 +207,15 @@ def main(): if interactive: nic = make_menu(interfaces) else: - nic[0] = options[0] + nic = options + found = False + for i in interfaces: + if nic[0] == i[0]: + found = True + break + if not found: + err = '%s: No such interface' % nic[0] + raise RuntimeError(err) if nic: if interactive: (ip,mask,gw) = get_config() -- 2.39.2