-3

I am parsing the ip address in command line. But i don't know how to write the script to check a ip address is alive or not.

I don't know how write for linux & windows platform as well

Sample:

python testIP.py 10.1.1.1

Output should return: true(success) or false(fail)

Abhis
  • 585
  • 9
  • 25
SSH
  • 73
  • 8
  • Checking with what ? A ping ? – FunkySayu Aug 13 '15 at 12:09
  • Check this: http://stackoverflow.com/questions/2953462/pinging-servers-in-python - here you'll find some answer. So this is possible duplicate anyway. – Faflok Aug 13 '15 at 12:41
  • Can you describe more broadly what you are trying to accomplish? Why do you want to know if an "ip address is alive"? What do you plan to do with that information? (I ask because I suspect that you are asking an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) question.) – Robᵩ Aug 13 '15 at 14:08

1 Answers1

0

IP addresses aren't "alive". An IP address is something which is local / internal to a computer. You can't "check" it from outside without additional help. One such way is the "ping" service which responds to packages sent by the ping command. So you need to determine which service you want to check and then write a Python script that tries to connect to this service to see whether it is alive.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820