def fping(self, cmd):
print("{i} {c}".format(i=ctinfo, c=' '.join(cmd)))
logging.info(' '.join(cmd))
command = subprocess.run(cmd, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, universal_newlines=True, shell=False)
wrapper = TextWrapper(initial_indent="{i} ".format(i=ctinfo),
subsequent_indent="{i} ".format(i=ctinfo))
if len(command.stdout.split("\n")) > 2:
output = wrapper.fill(command.stdout.replace("\n", ", "))
output = output.rstrip(',')
# TODO: write a function for this (in misc maybe) that cleans the target
# and adds it if not a hostname (hostnames will be resolved & IP's added)
for host in command.stdout.split("\n"):
self.up_targets_dict.append(host)
elif len(command.stdout.split("\n")) > 1:
output = wrapper.fill(command.stdout.strip("\n"))
for host in command.stdout.split("\n"):
self.up_targets_dict.append(host)
else:
output = wrapper.fill("No Response")
print(output)
logging.info("Results: {r}".format(r=command.stdout.replace("\n", ", ")))
评论列表
文章目录