Suppress stderr to allow tshark to continue despite field errors

Redirect stderr to /dev/null to suppress 'Some fields aren't valid' errors
when tshark encounters frames without RA/TA fields. This should allow
tshark to continue capturing instead of exiting early.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Robert McMahon 2026-02-13 14:05:34 -08:00
parent 189444c88f
commit aed791efae
1 changed files with 4 additions and 6 deletions

View File

@ -137,11 +137,9 @@ echo "Capturing packets for $DURATION seconds..."
# We'll capture both stdout and stderr, but continue even if tshark exits with an error # We'll capture both stdout and stderr, but continue even if tshark exits with an error
set +e # Temporarily disable exit on error set +e # Temporarily disable exit on error
# Use -q to suppress packet count output # Use -q to suppress packet count output
# Use display filter to only capture frames that have RA/TA fields # Redirect stderr to /dev/null to suppress "Some fields aren't valid" errors
# This prevents tshark from erroring when it encounters frames without these fields # This allows tshark to continue even when encountering frames without RA/TA
CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -q -i "$INTERFACE" -n \ CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -q -i "$INTERFACE" -n -T fields \
-Y "(wlan.ra) || (wlan.ta)" \
-T fields \
-e frame.number \ -e frame.number \
-e frame.time \ -e frame.time \
-e wlan.ra \ -e wlan.ra \
@ -150,7 +148,7 @@ CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -q -i "$INTERFACE" -n \
-e wlan.fc.subtype \ -e wlan.fc.subtype \
-e wlan.fc.type_subtype \ -e wlan.fc.type_subtype \
-e radiotap.present \ -e radiotap.present \
2>&1) 2>/dev/null)
CAPTURE_EXIT_CODE=$? CAPTURE_EXIT_CODE=$?
set -e # Re-enable exit on error set -e # Re-enable exit on error