tcpdump capture

I need a way of automating PCAP Packet capture. I could use Wireshark but I want a more command line mechanism.

The Script

#!/bin/bash
echo "Filename "
read fn
echo "Listen for (in Seconds)"
read sec
tcpdump -i any -w $fn".pcap"&
pid=$!
sleep $sec
kill $pid
echo "Completed"

To Run simply

./record.sh