Below is a simple Python code that accepts IP Address as input and check or ping the IP Address and shows an output whether its up or down.
Some network disable ICMP request, so no matter how you try the system will not reply to the ping request.
Code below is great when you're getting hands wet on simple Python script.
Here's the code:
#!/usr/bin/python3
import subprocess as subps
import sys
def ipcheck(check_ice):
status,result = subps.getstatusoutput("ping -c1 -w2 " + str(check_ice))
if status == 0:
print("Device " + str(check_ice) + " is UP!")
print(status,result)
else:
print("Device " + str(check_ice) + " is DOWN!")
ipcheck(str(sys.argv[1]))
#================
Works great on Linux system.
For Windows, run on WSL environment.
Type: wsl to enable WSL
Then change directory to: /mnt/c/Users/<username>/Documents
Or cd /mnt/c/<browse to where the python script is located>
On the location where the script is located type, the command below to run the Python code:
python3 file_name.py <ip.add.ress.to.test>
/mnt/c/ <-- c is the drive letter where the windows directory is located.
Here's some screenshot on WSL.
Cheers! Take care. Till next Time.
Stay safe! and Keep things up!
Do ASAP, Always Say A Prayer...
Practice O.T.G. = Obedience To God
================================
Free Android Apps:
Click links below to find out more:
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
Divine Mercy Chaplet Guide (A Powerful prayer) BFF = Be Filled Faith:
Comments
Post a Comment