Skip to content

Instantly share code, notes, and snippets.

@tomquas
Forked from tehmaze/vmdump.sh
Last active December 24, 2015 13:49
Show Gist options
  • Save tomquas/6808027 to your computer and use it in GitHub Desktop.
Save tomquas/6808027 to your computer and use it in GitHub Desktop.
#!/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
/Applications/VMware\ Fusion.app/Contents/Library/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: sudo $(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