[asterisk-users] Running System() after call completion, not in 'h'?

Tim Nelson tnelson at rockbochs.com
Tue Aug 31 10:13:47 CDT 2010


----- "Steve Edwards" <asterisk.org at sedwards.com> wrote:
> On Tue, 31 Aug 2010, Tim Nelson wrote:
> 
> > I have some dialplan code on an Asterisk 1.2.x box that basically
> dials 
> > a call, then after call completion, runs a command via System(). 
> > However, I'm finding that roughly 5% of the time, the System()
> command 
> > never executes and seems to be on specific destinations. 
> > Simplified/paraphrased example:
> >
> > exten => 1,1,Set(VARIABLE=SOMEVALUE)
> > exten => > 1,n,Dial(SIP/somepeer/1234567980)
> > exten => 1,n,System(/bin/bash > /root/bin/somescript.sh ${VARIABLE}
> >
> > It almost seems to be related to how fast the destination 'hangs up'
> and 
> > whether or not the dialplan has time to run the System command
> before 
> > jumping to 'h'.
> >
> > I have to believe there is a better way to do this, possibly using 
> > DeadAGI?
> 
> I think you're on the right track -- moving from system() to
> [dead]agi().
> 
> I think you should be using agi() instead of deadagi() since the call
> 
> isn't "dead" yet. IMO, trapping HUP is a prerequisite for a "well
> written 
> AGI."
> 

The problem is that the call is hitting the 'h' extension "too quickly". And, unfortunately, in 'h', the variables I set earlier are already gone so I cannot simply run the System() from 'h'.

Is there any situation where 'h' would not be called? I could certainly do the work in DeadAGI() via 'h' knowing it would be called regardless of timing.

--Tim



More information about the asterisk-users mailing list