[prog] bash script - mac address compare and send email

Far Jump far.jmp at gmail.com
Tue Mar 24 03:28:01 UTC 2009


Chris,

the problem is not in -eq ... we know this works.  Your MAC1 is straight forward, so tshark must be return something unexpected or additional ... try echo it out to stdout to see or better write the script in perl or ruby to help you debug what is really going on.  Ruby is great cause it gives you a dump function on string objects.

good luck,
Jan
______________________________________________________________________
 Greater love has no one than this, that he lay down his life for his friends.
   -- John 15:13

---------------------- Reply to Message Below ----------------------
I'm trying to write a script that will compare MAC address and send
out an email. But it's not working as expected. I have tried both
"-eq" and "==" - but guess the problem is somewhere else. I want to
run this program in the background (with &)

Thanks for any help.

#!/bin/bash

set -x

MAC_AS_READ_FROM_TSHARK=$(tshark -i eth0 -n port 68 -R 'bootp.type ==
2' -o column.format:'"Source MAC","%hs"')

MAC1="00:1F:32:6D:BB"

if [ "$MAC_AS_READ_FROM_TSHARK" -eq "$MAC1" ]; then
            echo "foo" | mail -s "foo" foo at bar
fi
_______________________________________________
Programming mailing list
Programming at linuxchix.org
http://mailman.linuxchix.org/mailman/listinfo/programming



More information about the Programming mailing list