diff --git a/horde/horde.py b/horde/horde.py index 55b1cef..abc1f9b 100755 --- a/horde/horde.py +++ b/horde/horde.py @@ -161,16 +161,15 @@ def local_ip(): def hordemain(): if not os.path.exists(opts['hosts']) and opts['hostlist'] is False: - sys.exit('ERROR: hosts file "%s" does not exist' % opts['hosts']) - - if opts['hosts']: + hosts = [line.strip() for line in sys.stdin] + elif opts['hosts']: hosts = [line.strip() for line in open(opts['hosts'], 'r')] - # filter out comments and empty lines - hosts = [ - host for host in hosts if not re.match("^#", host) - and host is not ''] else: hosts = opts['hostlist'].split(',') + # filter out comments and empty lines + hosts = [host for host in hosts if not re.match("^#", host) and not host == ''] + if len(hosts) == 0: + sys.exit('ERROR: No hosts provided.') # handles duplicates hosts = list(set(hosts)) log.info("Running with options: %s" % opts)