Created
October 9, 2018 13:49
-
-
Save 0xIslamTaha/2d1f44df9dc0e2d4399e32f2d88b23ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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