[asterisk-users] 10 Caller IDs to be used randomly or progressively

Markus universe at truemetal.org
Thu Sep 19 09:58:24 CDT 2019


Am 18.09.2019 um 01:15 schrieb bilal ghayyad:
> I have 10 Caller IDs and I need each call (each time) to use one of 
> these Caller IDs to be the caller id.

exten => 1234,1,AGI(/var/lib/asterisk/randomcli.sh)


randomcli.sh:


#!/bin/bash

WORDFILE="/var/lib/asterisk/mobilecliall.txt"

NUMWORDS=1

#Number of lines in $WORDFILE
tL=`awk 'NF!=0 {++c} END {print c}' $WORDFILE`

for i in `seq $NUMWORDS`
do
rnum=$((RANDOM%$tL+1))
CIDNAME=$(sed -n "$rnum p" $WORDFILE)
done

echo $CIDNAME
echo "Setting CallerID to: \"\"<$CIDNAME>" >&2
echo "SET CALLERID \"\"<$CIDNAME>"


Then put your 10 CLIs in mobliecliall.txt.


PS: Shorter version for randomcli.sh, same functionality:

#!/bin/bash

CIDNAME=$(shuf -n 1 mobilecliall.txt)
echo "SET CALLERID \"\"<$CIDNAME>"


:-))

Regards
Markus



More information about the asterisk-users mailing list