I hope this helps . This is a bit of a shambles. You've got an unterminated strings all over the place, your spacing is incorrect around your square brackets, and you're quoting numbers as strings. Since you're using /bin/bash you can use Bash conditionals. As well, variable interpolation is better done with printf instead of embedding variables in strings. Try something like this:
#This script emails the recorded call right after the call is hung up. Below are the variables passed through asterisk
# $1 - year
# $2 - month
# $3 - day
# $4 - Time String
# $5 - Source
# $6 - File
# $7 - Destination
# $dt - Date and Time
dt=$(date '+%m/%d/%Y %r');
printf 'You have a new call recording to listen to \n\n The call date and time was %s \n\n The call was from %s \n\n The call was to %s \n\n' "$dt" "$5" "$7"
if [[ $5 -gt 100 ]] && [[ $5 -lt 1000 ]]; then
printf 'Please see the attached file \n\n' | mail -a "/var/spool/asterisk/monitor/$1/$2/$3/$6" -s "New Call Recording" "email@example.com"
elif [[ $5 -ge 1000 ]]; then
printf 'Please see the attached file \n\n' | mail -a "/var/spool/asterisk/monitor/$1/$2/$3/$6" -s "New Call Recording" "firstname.lastname@example.org"
should help you out I am developing a C#.NET Windows Application using Asterisk.NET Library. In my application NewState Event is triggered even when I originate the call (when it rings the source). I want only incoming calls to be shown as "Somebody is calling". Now it shows even for self-ringing calls (when originating),,, How can I check and avoid Originated calls from Newstate Event. Please Help.. , Simplest way: 1) create originate with
Any of those help I created the patch for asterisk 13 =) In short, the algorithm of the cdr remained the same, which eliminates various errors. If CDR record is the most latter, then we write it. And the last record is exactly what we need. Tested on version 13.4 and 13.6. Install: Patch asterisk source code and build/rebuild asterisk.