#!/usr/bin/env python import sys, socket services = [ ('caffeine.csclub.uwaterloo.ca', [22, 25, 80, 110, 143, 143, 443, 465, 587, 993, 995]), ('artificial-flavours.csclub.uwaterloo.ca', [22, 389, 636]), ('taurine.csclub.uwaterloo.ca', [22]), ('natural-flavours.csclub.uwaterloo.ca', [22]), ('mirror.csclub.uwaterloo.ca', [21, 22, 80, 873]), ('denardo.csclub.uwaterloo.ca', [22]), ('corn-syrup.csclub.uwaterloo.ca', [22]), ('ascorbic-acid.csclub.uwaterloo.ca', [21, 22, 53, 80, 81, 443, 8000, 8080]), #all ssh ('ginseng.csclub.uwaterloo.ca', [22, 111, 389, 464, 636, 749, 888, 2049]), ('webauth.csclub.uwaterloo.ca', [22, 443]), ('wiki.csclub.uwaterloo.ca', [80, 443]), ] for S in services: try: host = socket.gethostbyname(S[0]) for port in S[1]: s = socket.socket() s.connect( (host , port) ) s.close() except socket.error, e: print "FAIL socket connect to ", S, e sys.exit(1)