Skip to content

Instantly share code, notes, and snippets.

@tehmaze
Created July 31, 2011 16:37
Show Gist options
  • Save tehmaze/1116940 to your computer and use it in GitHub Desktop.
Save tehmaze/1116940 to your computer and use it in GitHub Desktop.
tcpdump for VMWare Fusion
#!/bin/bash
if echo ${1} | grep -q '^vmnet[0-9]$'; then
ERRCOUNT='0'
PIDSNIFF='0'
PIDTDUMP='0'
CAPINTF="${1}"
CAPFILE="$(mktemp -t capture)"
trap "rm -rf \"${CAPFILE}\"" EXIT TERM INT
shift
if rm -f "${CAPFILE}"; then
if mkfifo "${CAPFILE}"; then
/Library/Application\ Support/VMware\ Fusion/vmnet-sniffer \
-w "${CAPFILE}" "${CAPINTF}" >/dev/null || let ERRCOUNT++ &
tcpdump -r "${CAPFILE}" ${*} || let ERRCOUNT++ &
wait
else
let ERRCOUNT++
fi
else
let ERRCOUNT++
fi
else
let ERRCOUNT++
echo "usage: $(basename ${0}) <vmnet interface> [tcpdump options]"
fi
exit "${ERRCOUNT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment