#!/usr/bin/python3 import sys import re if __name__ == '__main__': if len(sys.argv)>1: port_range = sys.argv[1] if re.search('[0-9]{1,5}-[0-9]{1,5}', port_range): for tmp in port_range.split('-'): if int(tmp) not in range(1, 65535): print(f'Error: {port_range} is not a valid port range') sys.exit(1) else: if int(port_range) not in range(1, 65535): print(f'Error: {port_range} is not a valid port') sys.exit(1) else: sys.exit(2) sys.exit(0)