#!/bin/bash

# dump velodyne packets
# $Id: vdump 8892 2009-10-24 15:13:57Z joq $

if [ x$1 = x ]
then	echo -e "usage:\t`basename $0` file-prefix [ interface ]"
	echo -e "\n\tfile-prefix is completed with a three-digit number"
	echo -e "\tinterface default is 'eth0'\n"
	exit 9
fi

IF=${2:-eth0}
UN=`id -un`
ID=`id -u`

echo "acquiring packets on $IF for user $UN; press ^C when done"

if [ $ID = 0 ]; then
  /usr/sbin/tcpdump -i $IF -s 0 -C 100 -W 999 -w $1
else
  sudo /usr/sbin/tcpdump -i $IF -Z $UN -s 0 -C 100 -W 999 -w $1
fi
