python_wiki:test_port

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
python_wiki:test_port [2014/11/19 22:25]
billdozor created
python_wiki:test_port [2019/05/25 23:50] (current)
Line 1: Line 1:
 ====== Test Port ====== ====== Test Port ======
 +
 +**General Information**
 +
 Function to check a network port to see if it is open on a host. Function to check a network port to see if it is open on a host.
  
-<code>+**Checklist** 
 +  * import socket 
 + 
 +---- 
 + 
 +====== Usage ====== 
 + 
 +Call this function, checking server1 for tcp/22 (ssh): 
 +<code python> 
 +if test_port(server1,22): 
 +  do ssh stuff 
 +else: 
 +  print("Server not listening on tcp/22!"
 +</code> 
 + 
 +---- 
 + 
 +====== The Code ====== 
 + 
 +<code python>
 import socket import socket
  
Line 18: Line 40:
 </code> </code>
  
-Call this function, checking server1 for tcp/22 (ssh): +---- 
-<code> +
-if test_port(server1,22): +
-  do ssh stuff +
-else: +
-  print("Server not listening on tcp/22!"+
-</code>+
  • python_wiki/test_port.1416453949.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)