I'm trying to ping a specific ip address that is input after the application is run. Here is my current code, but every time I input an IP it comes up with errors saying invalid syntax. I've searched other topics but they involve pinging a range of IP's at once. Thanks for your help.
def pingComputer():
import os
hostname = input("Enter the ip address: ")
response = os.system("ping -c 1 " + hostname)
if response == 0:
print hostname, 'is up!'
else:
print hostname, 'is down!'
Aucun commentaire:
Enregistrer un commentaire