Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
watch netstat -n -A inet             + notify-send "Attention new  connection"

or

watch  cat /proc/net/ip_conntrack    + notify-send "Attention new  connection"

or

watch ss -n                          + notify-send "Attention new  connection"

Do you have any idea how to connect this halves and thank you.

share|improve this question
    
Wait a minute... you want a notification each time a socket is opened? –  Braiam Dec 12 '13 at 23:41
    
Which desktop manager are you using? as with some you can set a notification anyway. –  Wilf Dec 12 '13 at 23:43
add comment

1 Answer

What you need is a short bash script, like:

#!/bin/sh
while [ 1 ]
do
  if [ "PARAMETER" = "SOMETHING" ]; then
     notify-send "Attention" "There is a new connection."
  else
     echo "Nothing Found"
  fi
  sleep 5
done

Basically, this would listen for a PARAMETER (How, I don't know...), and when it equals SOMETHING, then it will send a notification. If the PARAMETER is not equal to SOMETHING, it will print Nothing Found (This is not necessary, it just shows that it is working), wait for 5 seconds, and start again.

The problem is getting it find when it has connected... None of these...

  • netstat -n -A inet
  • cat /proc/net/ip_conntrack - apparently deprecated anyway, see here
  • ss -n

...seem to produce the parameters required...


Any corrections welcome, especially with the bash script

share|improve this answer
add comment

Your Answer

 
discard

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.