How to grab command return values

If I use waitforring command, it will exit with either a return value of 0 or -1.
How do I capture this return value in my dial plan?


If these are the return codes from the subroutines that implement the application, you know you got zero because the dialplan is still running. If you get -1, it may run the h extension, but otherwise terminates the call.

The problem is knowing why there was a hangup. If busydetect goes to the h extension, I cannot grab any variable or return value that says, “ok, we are here because we detected busy”.
I would like to know that the hangup is due to busy detection. Right now, I cannot find a way to do this in the h extension.
thanks for your reply

Never tried it for the waitforring but wat does

exten => h,1,Noop(${dialstatus})
exten => h,2,Noop(${hangupcause})


That wasn’t your original question!

The documentation of WaitForRing in TFOT and on voip-org looks broken to me. Is what you are trying to do is to implement an answering machine where a parallel connected “extension” will abort the answering, if it is picked up first, and you want to be able to determine whether the caller abandoned or the parallel phone picked up?

If hangupcause isn’t set, I’m afraid you’ll have to modify the deeper source code to set a variable.

The waitforring does not seem to work at all in testing last night with a simple fxo trunk. It does not fallthrough with ringing and does not even timeout. I reviewed this with the log file as well. dialstatus and hangupcause not useful.

I tried to grab the return value with busydetect, but dialstatus is empty, hangupcause is 0.
You’d think busydetect would set a variable that can be used in the inevitable h extension.

Guess the only way is to set a variable within the source.

Looking at your BUSYDETECT question, I think you may have misunderstood WaitForRing. I get the impression that busy detect is for outgoing calls, but WaitForRing is for incoming calls, although I have used neither of them.