logo
down
shadow

Asterisk Creating Script that Emails based on where call originated


Asterisk Creating Script that Emails based on where call originated

Content Index :

Asterisk Creating Script that Emails based on where call originated
Tag : bash , By : George H.
Date : November 28 2020, 04:01 AM

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:
#!/bin/bash
#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" "email1@domain.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" "email2@domain.com"

 fi

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to differentiate Incoming call and Originated Call in Asterisk.NET NewState Event


Tag : chash , By : Adrian Codrington
Date : March 29 2020, 07:55 AM
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
Channel: Local/1234@dialout
Set: id=1
Set: otherinfo="nice call"
[dialout]
exten =>_X.,1,UserEvent(CatchMe,number: ${EXTEN}, db_id: ${id}, otherinfo: ${otherinfo})
exten =>_X.,2,Dial(SIP/${EXTEN}@outtrunk,,)

Linux Asterisk script for test call


Tag : linux , By : Tim Coffman
Date : March 29 2020, 07:55 AM
To fix this issue I would suggest using Asterisk Call Files
Create a file name /tmp/example.call such as:
Channel: SIP/peerdevice/1234
Application: Playback
Data: silence/1&tt-weasels 
cp /tmp/example.call /tmp/example.call.new
mv /tmp/example.call.new /var/spool/asterisk/outgoing
[somecontext]
exten => 1234,1,Answer()
same =>       n,Noop(Example call inbound)
same =>       n,Playback(hello-world)
same =>       n,Hangup()

Asterisk-java originated call's billsec and other data


Tag : java , By : lewing
Date : March 29 2020, 07:55 AM
may help you . You need mark CDR(userfield) or CDR(accountcode) in dialplan
After that you can collect cdr in mysql or other database on your request.

Asterisk 13.4 cdr engine is creating 2 records per call


Tag : development , By : Rit Li
Date : March 29 2020, 07:55 AM
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.

FreePBX/Asterisk run script on call


Tag : php , By : Ryuken
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • I want my script to echo "$1" into a file literally
  • Shell script: unexpected token ´if"
  • scp error when defining a "PATH" variable in a bash script
  • Nested loop for reading two files with bash
  • Find folders with a specific name and run bash commands on each location
  • Replication and expansion of program flags in BASH script
  • Error on certain line: Syntax error: "(" unexpected
  • Terminal not returning to normal after Bash Script
  • what code function will help to ask for input when i try to execute a code with no previous value in shell script
  • “How to fix ‘Syntax Error Near’ error in BASH”
  • How to generate all ASCII characters with a brace expansion?
  • Why does `export` fail on bad substitutions but not command failures?
  • I am trying to get a public IP from an instance I am just starting up
  • How to run a bash script, but skip the last 2 lines?
  • Google Cloud Storage - Create many copies of a single object/file quickly
  • find all matches between two files then append character to beginning all matches in the second file
  • How to print 02-Jun-2019 in bash
  • added wrong path to .bash_profile now I can not found any command
  • How can I pick every line of a file with a match and do operations with it?
  • How to use awk and read together in bash script?
  • syntax error near unexpected token `(' when defining function in bash profile
  • How can I read a stream of key=value pairs in bash if the values can be empty?
  • How to get last sunday's date from today's date using shell script?
  • How to exec bash script w/o exiting shell
  • How to use an external variables file inside a script
  • How to run commands in parallel in bash?
  • mkdir no such file or directory syntax error?
  • How to write for loop to fetch data to newly created file?
  • Translate git-log old commiter timestamp to strict ISO 8601 timestamp
  • move files that no not contain specific string
  • How to group by one column and divide the numbers in second column depending from the third
  • Bash get the command that is piping into a script
  • while read line not working on mac with makefile
  • How to redirect A's stdout to B's stdin and B's stdout to A's stdin?
  • echo is not entered into hash table
  • sed an remove everything after the first pattern (only in the line)
  • Bash using cut to separate an IP and Port
  • Can a shebang refer to a remote program?
  • Why I am not getting a value when i call a function within another in a bash script
  • Why does ". myscript" return file-not-found in only one Git for Windows sh.exe?
  • How to parse a rdf format file from command line
  • Unknown shorthand flag: 'd' in -d
  • Why does a pipeline reading from and writing to the same file result in a blank file?
  • why the code inside EOF shows this error?
  • Why should I add wait after done?
  • Script bash : Remove numbers from a file name between "-" and "_"
  • How to pass multiple commands to a single command in bash using &&?
  • Bash Conditional Odd Behavior
  • Shell script read multiple inputs from user
  • Passing variables with spaces to function
  • Is the term trap (of Bash) more accurate than the generic "callback" term in programming?
  • How to extract only specific string matching lines from a multiple lines standard input
  • $BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?
  • Using awk to get lines between two patterns
  • -bash: emacs.profile: command not found
  • Write a script (or a command)
  • Using variables within a function (passing in a place holder)
  • Using SED to change name of object in txt
  • kB to MB using awk
  • Can't read with IFS and read
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com