Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106772

Re: Python,ping,csv

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Subject Re: Python,ping,csv
Date Sat, 9 Apr 2016 21:29:08 -0600
Lines 16
Message-ID <mailman.0.1460259273.424.python-list@python.org> (permalink)
References <o1JNy.43731$pt.31548@tornado.fastwebnet.it> <CANy1k1h392HiXq-onCAFj1zJkK0Z31AXeR6fEtnf7fZ-5fHkaQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de kLZWKR42/syV7CxzXgpclw32VM+/Y2UpHKkimOyj8hew==
Return-Path <jsf80238@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; 'subject:Python': 0.05; 'address)': 0.09; 'ping': 0.09; 'res': 0.09; 'python': 0.10; 'received:io': 0.16; 'received:psf.io': 0.16; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'print': 0.30; 'to:name :python-list': 0.30; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'received:209.85.220': 0.38; 'to:addr:python.org': 0.40; 'address': 0.61; 'address,': 0.77; 'subject:,': 0.82; "'3',": 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=Uk912/l8wS0+1nLZJRf6/e0YPkPrL5ZDSMbW09sYXHE=; b=wSK24yRvCTN+ikY3nBrskrfCAlZoDjbISrWoMqUvGlvfQCpdDlmrqtvApqZG6nJmV4 IFifmH/OAdwnIyCOOzyDBauQohDw6ks5ETZlAbPq8Wi10XSSQMpjG8PIF9kexnByAtLD 1MzstpalSlznzSqg5tev07Kt9frpsmCkwfO/LqR3Q5fWEHjQ0+MtQmhFRylUcRjpwPoo EapTE/x921DJ4n5Pv00bV4f6W1D2Gp1gM88WEOYaaxOhSeFR3GIhRWzTr8fs4JftSpyv LN2ABGN6Ef1f9V+N1eD8gZdRPmB7UaJfYNrUJC9KF6B30NcjinCCpLnoNnFHl3ipvWOR UDXg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=Uk912/l8wS0+1nLZJRf6/e0YPkPrL5ZDSMbW09sYXHE=; b=I1fQn4XwNLLiQ5149SPnqMh/hroNAkU/DC6rx7eahIrwh5Mz81E7Smxp2ivFLNW0pN Z2+JwPEaaIj+vjJS+S4CJxIj9+zfTqISHQK+xLMR3N3wXQBm7EaFJEe0Qgg2UxI5TGlB Z2mXyEhF7Wmk3zEIIWXB8NhcKPRB/Y27kJRGar8+aAutRYWqLsA/MWPzxrRSb75kDRHO K8+DXd2EWXIAVsa5lEaSWAAEPBhZb175Fl+T3C8ynMFxbqjpPuQ5ysHFuuBdpLcfH3HJ ndIsHWJokfalO4quiENyVCL1qcfccLY7ppDjiCcQRLJrCHT+NwjPX7Gv8bKicCwY739f 1bLQ==
X-Gm-Message-State AD7BkJJhi9yu1rV7I7HdTeR4XmP0lt7WJNrvytMbJS/iLUqIWSE/BOAJKEp/Mf0XA+Ky5NZwthDFtYqxSv9kvQ==
X-Received by 10.55.78.11 with SMTP id c11mr20508192qkb.89.1460258948958; Sat, 09 Apr 2016 20:29:08 -0700 (PDT)
In-Reply-To <o1JNy.43731$pt.31548@tornado.fastwebnet.it>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CANy1k1h392HiXq-onCAFj1zJkK0Z31AXeR6fEtnf7fZ-5fHkaQ@mail.gmail.com>
X-Mailman-Original-References <o1JNy.43731$pt.31548@tornado.fastwebnet.it>
Xref csiph.com comp.lang.python:106772

Show key headers only | View raw


> for ping in range(1,254):
>     address = "10.24.59." + str(ping)
>     res = subprocess.call(['ping', '-c', '3', address])
>     if res == 0:
>         print ("ping to", address, "OK")
>     elif res == 2:
>         print ("no response from", address)
>     else:
>         print ("ping to", address, "failed!")

Note that with Python 3.3+ you can simplify slightly:

from ipaddress import IPv4Network
for address in IPv4Network('10.24.59.0/24').hosts():
    res = subprocess.call(['ping', '-c', '3', address])
    ...

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python,ping,csv Smith <smith@a-team.it> - 2016-04-08 09:25 +0200
  Re: Python,ping,csv Joel Goldstick <joel.goldstick@gmail.com> - 2016-04-08 05:18 -0400
  Re: Python,ping,csv Jason Friedman <jsf80238@gmail.com> - 2016-04-09 21:29 -0600
    Re: Python,ping,csv Smith <smith@a-team.it> - 2016-04-11 10:22 +0200
    Re: Python,ping,csv Smith <smith@a-team.it> - 2016-04-11 11:24 +0200
      Re: Python,ping,csv Jason Friedman <jsf80238@gmail.com> - 2016-04-11 19:17 -0600
      Re: Python,ping,csv Jason Friedman <jsf80238@gmail.com> - 2016-04-12 00:01 +0000

csiph-web