I code in both windows and Linux. As python is portable, the o/p should be same in both cases. But why the following code is perfect in windows but error one in Linux ???
from socket import * import sys status={0:"open",10049:"address not available",10061:"closed", 10060:"timeout",10056:"already connected",10035:"filtered",11001:"IP not found",10013:"permission denied"} def scan(ip,port,timeout): s = socket(AF_INET, SOCK_STREAM) s.settimeout(timeout) try: result= s.connect_ex((ip, port)) except: print "Cannot connect to IP" return s.close() return status[result] if (len(sys.argv) == 4): ip=sys.argv[1] minrange = int(sys.argv[2]) maxrange = int(sys.argv[3]) timeout = 3 ports=range(minrange,maxrange+1) for port in ports: print str(port) + " : " + scan(ip,port,timeout) else: print "usage : " + sys.argv[0] + " <ip-address> <min-port range> <max-port range>" -- http://mail.python.org/mailman/listinfo/python-list