Python Forum
Need some guidance on a script to ping a list of ip's
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some guidance on a script to ping a list of ip's
#11
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?
Reply
#12
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  non-stop ping script kucingkembar 1 2,179 Aug-23-2022, 06:29 AM
Last Post: menator01
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 5,297 May-17-2021, 11:29 AM
Last Post: throwaway34
  Ping command using python 3.6.5 Martin2998 6 28,313 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
  Your Guidance caslor 1 2,907 Mar-28-2021, 09:34 PM
Last Post: Larz60+
  Create a program that PING a list of IPs skaailet 7 10,294 Mar-26-2020, 10:46 PM
Last Post: snippsat
  ping with output jacklee26 1 6,224 Nov-28-2019, 01:01 PM
Last Post: Axel_Erfurt
  PING PONG GAME akea 0 6,435 May-08-2019, 04:30 PM
Last Post: akea
  Ping Code Problem MTom5 1 3,296 Sep-04-2018, 09:58 PM
Last Post: MTom5
  ping and pong run both well sylas 1 3,919 Sep-24-2017, 05:14 PM
Last Post: sylas
  Ping Sweep help The501stOfNoobPy 5 8,613 Jun-26-2017, 10:22 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020