Skip to content

Instantly share code, notes, and snippets.

@0xIslamTaha
Created October 9, 2018 13:49
Show Gist options
  • Save 0xIslamTaha/2d1f44df9dc0e2d4399e32f2d88b23ed to your computer and use it in GitHub Desktop.
Save 0xIslamTaha/2d1f44df9dc0e2d4399e32f2d88b23ed to your computer and use it in GitHub Desktop.
import collections
from subprocess import Popen, PIPE
def execute_cmd(cmd):
sub = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
out, err = sub.communicate()
return out, err
out, err = execute_cmd('ip n')
ip_n_data = str(out)
ip_n_data = ip_n_data.replace('\n', ' ')
node_ips = []
for data in ip_n_data.split(' '):
if "172.20" in data:
node_ips.append(data)
print([item for item, count in collections.Counter(node_ips).items() if count > 1])
from IPython import embed
embed()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment