Python script for tracert

cindy jones mailcindy at gmail.com
Wed Oct 1 01:49:09 EDT 2008


Thank you so much Gabriel.. It works

On Wed, Oct 1, 2008 at 3:25 AM, Gabriel Genellina <gagsl-py2 at yahoo.com.ar>wrote:

> En Tue, 30 Sep 2008 03:53:21 -0300, cindy jones <mailcindy at gmail.com>
> escribió:
>
>
> Hello.. I'm trying to do a scripting for tracert  in windows using
>> python...
>> I'm using popen(), but it displays only after the tracert is completed. i
>> want the results to be displayed for every route.
>>
>> can anyone help me in this..
>>
>
> Use the subprocess module:
>
> import subprocess
> host = 'www.microsoft.com'
> p = subprocess.Popen(["tracert", '-d', '-w', '100', host],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
> while True:
>    line = p.stdout.readline()
>    if not line: break
>    print '-->',line,
> p.wait()
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081001/e0726a2f/attachment.html>


More information about the Python-list mailing list