Answers for "python ping port"

2

python ping ip address

import os

ip_list = ['8.8.8.8']
for ip in ip_list:
    response = os.popen(f"ping {ip}").read()
    if "Received = 4" in response:
        print(f"UP {ip} Ping Successful")
    else:
        print(f"DOWN {ip} Ping Unsuccessful")
Posted by: Guest on August-22-2020
0

check remote port is open or not using python

def port_check(HOST):
   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   try:
      s.connect((HOST, int(22)))
      s.shutdown(2)
      return True
   except:
      return False
Posted by: Guest on August-10-2020

Python Answers by Framework

Browse Popular Code Answers by Language