Skip to content

Commit 5a4328a

Browse files
Merge pull request #444 from jinyoungHan/patch-2
Update to Python 3 format
2 parents 39febfe + b521ec0 commit 5a4328a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

PORT SCANNER.PY

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ remoteServer = raw_input("Enter a remote host to scan: ")
7878
remoteServerIP = socket.gethostbyname(remoteServer)
7979

8080
# Print a nice banner with information on which host we are about to scan
81-
print "-" * 60
82-
print "Please wait, scanning remote host", remoteServerIP
83-
print "-" * 60
81+
print("-" * 60)
82+
print("Please wait, scanning remote host", remoteServerIP)
83+
print("-" * 60)
8484

8585
# Check what time the scan started
8686
t1 = datetime.now()
@@ -94,19 +94,19 @@ try:
9494
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
9595
result = sock.connect_ex((remoteServerIP, port))
9696
if result == 0:
97-
print "Port {}: Open".format(port)
97+
print("Port {}: Open".format(port))
9898
sock.close()
9999

100100
except KeyboardInterrupt:
101-
print "You pressed Ctrl+C"
101+
print("You pressed Ctrl+C")
102102
sys.exit()
103103

104104
except socket.gaierror:
105-
print 'Hostname could not be resolved. Exiting'
105+
print('Hostname could not be resolved. Exiting')
106106
sys.exit()
107107

108108
except socket.error:
109-
print "Couldn't connect to server"
109+
print("Couldn't connect to server")
110110
sys.exit()
111111

112112
# Checking the time again
@@ -116,5 +116,5 @@ t2 = datetime.now()
116116
total = t2 - t1
117117

118118
# Printing the information to screen
119-
print 'Scanning Completed in: ', total
119+
print('Scanning Completed in: ', total)
120120

0 commit comments

Comments
 (0)