Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a Script that would automatically do a dump of the attack as soon as it exceeds a threshold. The scripts looks like the following:


while /bin/true; do
  pkt_old=`grep $interface: /proc/net/dev | cut -d :  -f2 | awk '{ print $2 }'`
  sleep 1
  pkt_new=`grep $interface: /proc/net/dev | cut -d :  -f2 | awk '{ print $2 }'`

  pkt=$(( $pkt_new - $pkt_old ))

  echo -ne "\r$pkt packets/s\033[0K"

  if [ $pkt -gt 10000  ]; then
    echo -e "\n`date` Under attack, dumping packets."
    tcpdump -nn -s0 -c 2000 -w $dumpdir/dump.`date +"%Y%m%d-%H%M%S"`.cap
    echo "`date` Packets dumped, sleeping now."
    sleep 300

I want the same Script to send an Email to a specified address to notify the Admin if the server was attacked. How should we achieve this?

share|improve this question
man mail: mail -s "Subejct" <Text> <User> – l1zard Aug 16 '13 at 18:23
I tried "echo Hey | mail -s Test" but nothing was received. – Asad Moeen Aug 16 '13 at 18:33
In /var/mail/mail I got this " Mailing to remote domains not supported" – Asad Moeen Aug 16 '13 at 18:35
Fixed it by installing sendmail, thanks. – Asad Moeen Aug 16 '13 at 18:44
@AsadMoeen Then please delete this question or provide your own answer and mark it as accepted, if you do not it will keep popping to the front page as a open question with no accepted answer. – Scott Chamberlain Aug 16 '13 at 22:09
up vote 0 down vote accepted

So I did it with the following command.

echo Hey | mail -s Test

The above command didn't work so I fixed it by installing sendmail which wasn't installed by default.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.