Re: Netstat Speed

2006-09-06 Thread Jorgen Grahn
On Sat, 2 Sep 2006 20:13:01 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Jorgen Grahn enlightened us with: >>| def ip_is_active(addr): >>| """Return success if 'addr' shows up in the output from 'netstat -an'. >>| We assume that a suitable version of netstat exists. >>| """ > >

Re: Netstat Speed

2006-09-02 Thread Jorgen Grahn
On Sat, 2 Sep 2006 13:22:59 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > DarkBlue enlightened us with: >> Following code works . > > No it doesn't - it's indented badly. I guess you mean something like: > > def activeip(checkip): > # if there is any line returned we set activeb to 1 indi

Re: Netstat Speed

2006-09-02 Thread Jorgen Grahn
On Sat, 2 Sep 2006 13:22:59 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: ... > def activeip(checkip): > # if there is any line returned we set activeb to 1 indicating that > # this ip is active during a netstat run > activeb = 0 > netstat = os.popen("netstat -a -

Re: Netstat Speed

2006-09-02 Thread DarkBlue
Sybren Stuvel wrote: > DarkBlue enlightened us with: >> Following code works . > > No it doesn't - it's indented badly. I guess you mean something like: > > def activeip(checkip): > # if there is any line returned we set activeb to 1 indicating that > # this ip is active during a netst

Re: Netstat Speed

2006-09-02 Thread Tal Einat
DarkBlue wrote: > Following code works . > My question is can I make it faster ? > Faster how? Are you calling this so many times that you need it to be extremely fast? Are you calling it on the same IP multiple times, on many different IPs at once, ...? > > def activeip(checkip): > # if the

Re: Netstat Speed

2006-09-02 Thread DarkBlue
s=line is actually indented even if it does not appear to be so :) Db -- http://mail.python.org/mailman/listinfo/python-list

Netstat Speed

2006-09-02 Thread DarkBlue
Following code works . My question is can I make it faster ? def activeip(checkip): # if there is any line returned we set activeb to 1 indicating that # this ip is active during a netstat run activeb=0 for line in os.popen("netstat -a -n | grep '%s'" % checkip)