It cannot be selected what messages are received by the modem, but in the eventhandler you can filter messages based on the numbers.
Usually all messages from ordinary phones are using international number format. Messages from operator may use national or alphanumeric format. Check from the one received promotion what is the value of
From_TOA. If it's not international, you can use this kind of a filter in eventhandler:
#!/bin/bash
if [ "$1" == "RECEIVED" ]; then
FROM_TOA=`formail -zx From_TOA: < $2`
if [[ "$FROM_TOA" == *$'international'* ]]; then
FROM=`formail -zx From: < $2`
# Do the actions...
fi
fi
'bash' Syntax Highlight powered by GeSHi It is also possible to filter messages based on the number, here is a simple example:
#/bin/bash
if [ "$1" == "RECEIVED" ]; then
# List must start and end with space:
ALLOWED_NUMBERS=" 358401234567 358401234568 "
FROM=`formail -zx From: < $2`
key=" $FROM "
if [[ $ALLOWED_NUMBERS == *$key* ]]; then
# Do the actions...
fi
fi
'bash' Syntax Highlight powered by GeSHi If the list of allowed numbers is very large, it might be better to use a file, or database to store them. Similarly, you can also make a list of disallowed numbers:
#/bin/bash
if [ "$1" == "RECEIVED" ]; then
# List must start and end with space:
DISALLOWED_NUMBERS=" 358401234567 358401234568 "
FROM=`formail -zx From: < $2`
key=" $FROM "
if [[ $DISALLOWED_NUMBERS == *$key* ]]; then
FROM=""
fi
if [ -n "$FROM" ]; then
# Do the actions...
fi
fi
'bash' Syntax Highlight powered by GeSHi Sample filtering by prefixes:
#!/bin/bash
if [ "$1" == "RECEIVED" ]; then
ALLOWED_PREFIXES="35845 35850"
FROM=`formail -zx From: < $2`
allow_from=0
for tmp in $ALLOWED_PREFIXES
do
if [[ $FROM == $tmp* ]]; then
allow_from=1
break
fi
done
if [ $allow_from -gt 0 ]; then
# Do the actions...
fi
fi
'bash' Syntax Highlight powered by GeSHi