Python Forum
Need some guidance on a script to ping a list of ip's - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Need some guidance on a script to ping a list of ip's (/thread-40509.html)

Pages: 1 2


RE: Need some guidance on a script to ping a list of ip's - cubangt - Aug-10-2023

I will try from the command line.. later this evening as the code is at home..

Now a separate question, which ill google today as time permits, but besides spyder is there any other good IDE's to use for writing python that have the ability to run the scripts and see outputs in the console?


RE: Need some guidance on a script to ping a list of ip's - snippsat - Aug-10-2023

(Aug-10-2023, 01:18 PM)cubangt Wrote: I will try from the command line.. later this evening as the code is at home..
You most remember to always work from a active environment,either from (base) or a own environment that you make.
This is the same for Anaconda or MiniConda.
Example
# I have my own environment that i activate 
G:\div_code\egg
λ G:\miniconda3\Scripts\activate.bat tom_env

# Install
(tom_env) G:\div_code\egg
λ pip install icmplib
Collecting icmplib
  Using cached icmplib-3.0.3-py3-none-any.whl (30 kB)
Installing collected packages: icmplib
Successfully installed icmplib-3.0.3
To make some code of what you try do.
# ip_lst.py
from icmplib import multiping

with open("ip_list.txt") as fp:
    hosts = multiping([ip.strip() for ip in fp], interval=0.4, concurrent_tasks=30)
    for host in hosts:
        if host.is_alive:
            print(f'{host.address} is up!')
        else:
            print(f'{host.address} is down!')
Running code.
(tom_env) G:\div_code\egg
λ python ip_lst.py
127.0.0.1 is up!
104.21.27.41 is up!
104.156.80.0/20 is down!
8.8.8.8 is up!
77.16.58.122 is down! 
(Aug-10-2023, 01:18 PM)cubangt Wrote: Now a separate question, which ill google today as time permits, but besides spyder is there any other good IDE's to use for writing python that have the ability to run the scripts and see outputs in the console?
Spyder is ok,can try PyScripter which i use for quick testing ,my main editor is VS Code.
I do lot from command so cmder is important,cmd/PowerShell is not good at all.
Also use ptpython in cmder.