0
votes

I have an Asterisk dialplan that executes a bash script that matches the callerID with a database to geolocate the caller (by matching country and area codes). Since the database is quite large (global scale), it takes up to 15 seconds to finish.

I need to run this script immediately after answering the call (in case the user hangs up before the call is finished), but don't want the user to wait for the script execution. The return values should ideally be processed at the end of the dialplan just before the hangup.

Q1: I found http://www.voip-info.org/wiki/view/Asterisk+AGI#Forkandcontinuedialplan which deals with my problem in regards to perl scripts. How do i accomplish the same in bash? I know I can send any bash script to the background by adding a "&" at the end, but I'm clueless how to do that in the dialplan / when using AGI scripts.

Q2: How can I process the values even if the user hung up before / the dialplan "exited non-zero"?

Thanks for your help!

1

1 Answers

2
votes

Use fastagi interface. Or fire UserEvent with AMI listener.

AGI is not designed to work like you want, so it will not work.

Sure you can use nohup command to get immortal bash script, but that is not the way it have be.