Skip to content

Instantly share code, notes, and snippets.

@photonxp
Last active August 29, 2015 13:57
Show Gist options
  • Save photonxp/9802141 to your computer and use it in GitHub Desktop.
Save photonxp/9802141 to your computer and use it in GitHub Desktop.
#netstate-anov_deadloop.py
# works for windows XP SP-2, python2.5
from subprocess import call
import time
import sys
default_netstat_arglist = "-anov"
def build_arglist_as_is():
one_space = " "
arglist_as_is = one_space.join(sys.argv[1:])
return arglist_as_is
arglist_passed = build_arglist_as_is()
arglist_passed_len = len(arglist_passed)
arglist = default_netstat_arglist
if arglist_passed_len > 0:
arglist = arglist_passed
# call the nestat command and clear the screen before refresh it.
while True:
call(["netstat", arglist], shell=True)
time.sleep(4)
# There would be errors if arg shell=True is omitted.
call(["cls"], shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment