Does Python have a way to natively drip an IP?

Asked

Viewed 336 times

0

Is there any way to drip an IP natively into python, or a library?

For example, I do so:

import os
ips = ["192.168.0.1","192.168.0.2","192.168.0.3"] 
cmd = "ping -n 3 "
for ip in ips:
    print(os.popen(cmd + ip).readlines())

Have some other way than using command (ping -n 3 192.168...) from the platform itself (linux, windows, macos...)?

1 answer

2


There’s the Pyping that you can use, and any other way to use ping is by triggering it by the system itself other than this.

Use Pip to install:

pip install pyping

Take an example:

import pyping

r = pyping.ping('192.168.0.1')
print(r.ret_code)

Important

If you are using Pyping make sure to run the script as 'Administrator' if it is on Windows.

  • Perfect, thanks. Just one observation, I can only use it in python2.7, which for me is already great. It didn’t work in python3.7. No 3.7 of this message: Modulenotfounderror: No module named 'core'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.