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()
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()