From b606caa688a2fd65309c9918ced2db68cfd974ef Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sat, 12 Sep 2026 20:51:46 -0500 Subject: [PATCH] Update client.py --- MP1/client.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/MP1/client.py b/MP1/client.py index 91d5d83..0bd4618 100644 --- a/MP1/client.py +++ b/MP1/client.py @@ -68,15 +68,17 @@ def grep_all_ips(ips, cmd): return match_count -while True: - cmd = input(">> ").strip() - match_count = grep_all_ips(ALL_IPS, cmd) +#get all the argument of call +import sys - print("=========================== SUMMARY ===========================") - for i, count in enumerate(match_count): - if count == -1: - print(f"machine.{i + 1}.log: Connection failed") - else: - print(f"machine.{i + 1}.log: {count} matches") - print(f"Total matches: {max(0, sum(match_count))}") - print("===============================================================") \ No newline at end of file +cmd = " ".join(sys.argv[1:]) +match_count = grep_all_ips(ALL_IPS, cmd) + +print("=========================== SUMMARY ===========================") +for i, count in enumerate(match_count): + if count == -1: + print(f"machine.{i + 1}.log: Connection failed") + else: + print(f"machine.{i + 1}.log: {count} matches") +print(f"Total matches: {max(0, sum(match_count))}") +print("===============================================================") \ No newline at end of file