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


Groups > comp.lang.python > #106667

Re: Python,ping,csv

From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Subject Re: Python,ping,csv
Date 2016-04-08 05:18 -0400
Message-ID <mailman.75.1460107100.2253.python-list@python.org> (permalink)
References <o1JNy.43731$pt.31548@tornado.fastwebnet.it> <CAPM-O+zNiCCMd1i7WD_k-Netyu6zx3muc8hcKPzkyfZRkQdcDg@mail.gmail.com>

Show all headers | View raw


On Fri, Apr 8, 2016 at 3:25 AM, Smith <smith@a-team.it> wrote:
> Hello to all,
> I have this little script that pings certain ip addresses.
> Considering that I am a newbie to the Python programming language, can you
> help me change these lines in order to put the output into a csv file?
> Sorry for unclear English
> Thanks in advance
>
>
> import subprocess
>
> 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!")
> --
> https://mail.python.org/mailman/listinfo/python-list

What do you want in your csv file?  Show a sample output

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays

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