From 77fb5c69d4b3120f94119f2aa21da26033cae5f5 Mon Sep 17 00:00:00 2001 From: Robert McMahon Date: Fri, 13 Feb 2026 15:51:57 -0800 Subject: [PATCH] Only show tcpdump message when tcpdump is available - Check for tcpdump availability before printing startup message - Show 'Note: tcpdump not found, skipping concurrent count' when unavailable - Prevents confusing message when tcpdump is not installed Co-authored-by: Cursor --- wifi_monitor.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/wifi_monitor.py b/wifi_monitor.py index 1a91ef4..d5badf7 100755 --- a/wifi_monitor.py +++ b/wifi_monitor.py @@ -887,9 +887,23 @@ class PacketCapture: pcap_file.close() print(f"Capturing to file: {pcap_path}") - # Start tcpdump counter concurrently - print("Starting concurrent tcpdump counter for data frames...") - tcpdump_task = asyncio.create_task(self._run_tcpdump_counter(interface, duration)) + # Start tcpdump counter concurrently (only if available) + tcpdump_task = None + try: + # Check if tcpdump is available before starting + check_proc = await asyncio.create_subprocess_exec( + "which", "tcpdump", + stdout=asyncio.subprocess.DEVNULL, + stderr=asyncio.subprocess.DEVNULL + ) + await check_proc.wait() + if check_proc.returncode == 0: + print("Starting concurrent tcpdump counter for data frames...") + tcpdump_task = asyncio.create_task(self._run_tcpdump_counter(interface, duration)) + else: + print("Note: tcpdump not found, skipping concurrent count") + except Exception: + print("Note: tcpdump not found, skipping concurrent count") capture_error = None try: @@ -928,8 +942,10 @@ class PacketCapture: import traceback traceback.print_exc() - # Get tcpdump count - tcpdump_data_count = await tcpdump_task + # Get tcpdump count (if task was started) + tcpdump_data_count = None + if tcpdump_task is not None: + tcpdump_data_count = await tcpdump_task self.analyzer.analyze(packets, duration, tcpdump_data_count)