1

I want to execute a script on call hangup so I created a custom context in extensions_custom.conf as below:

[coscon]
exten => **5,1,NoOp()
same => n,Answer()
exten => h,1,System(/usr/local/src/myscript.php)

the problem is after hangup h extension in this context is not executing at all. any advice?

Update

let me elaborate it. in extensions_custom.conf file I include coscon context. this is the context of extensions_custom.conf:

[from-internal-custom]
exten => 1234,1,Playback(demo-congrats)  ; extensions can dial 1234
exten => 1234,2,Hangup()
exten => h,1,Hangup()
include => coscon

[coscon]
exten => **5,1,NoOp()
same => n,Answer()
exten => h,1,System(/usr/local/src/myscript.php)

Now when I call **5 from a softphone this is the Astrisk CLI output:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
    -- Executing [**5@from-internal:1] NoOp("SIP/102-00000035", "") in new stack
    -- Executing [**5@from-internal:2] Answer("SIP/102-00000035", "") in new stack
    -- Executing [**5@from-internal:3] Pickup("SIP/102-00000035","5&5@PICKUPMARK") in new stack
[2017-06-13 21:10:39] NOTICE[10676][C-00000035]: app_directed_pickup.c:302 pickup_exec: No target channel found for 5@from-internal.
[2017-06-13 21:10:39] NOTICE[10676][C-00000035]: app_directed_pickup.c:302 pickup_exec: No target channel found for 5@PICKUPMARK.
    -- Executing [**5@from-internal:4] Hangup("SIP/102-00000035", "") in new stack
    == Spawn extension (from-internal, **5, 4) exited non-zero on 'SIP/102-00000035'
    -- Executing [h@from-internal:1] Hangup("SIP/102-00000035", "") in new stack
    == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/102-00000035'

I think the default h extension for from-internal context is executing but I don't know how to override it.

miken32
  • 42,008
  • 16
  • 111
  • 154
AmirA
  • 133
  • 2
  • 15

1 Answers1

2

You issue is following:

Let say you have 2 context

[a]
exten => h,1,Noop(a)
exten => 1,1,Noop(1)
include => b
[b]
exten => h,1,Noop(b)
exten => 2,1,Noop(2)

If your context is [a], it include [b],yes. BUT if extension exist in [a], it will be executed in [a], not in [b]. So h extension will be executed from context[a].

if you want that work, you have do like this:

   [b]
    exten =>h,1,Noop(b)
    exten => 2,1,Goto(${EXTEN},2); now even if included, you WILL BE in context b
    exten => 2,2,Noop(2);this one alway context b
arheops
  • 15,544
  • 1
  • 21
  • 27
  • Sir, as you can see from asterisk cli log extension **5 is executing. that's not the problem. my problem is only h extension. I tried your solution with no luck. Thanks anyway. – AmirA Jun 17 '17 at 05:32
  • I see from your log h@from-internal:1] Hangup("SIP/102-00000035", that mean you context a=from-internal execute FIRST h-extension(in from-internal-custom). it work like it SHOULD, no problem here. – arheops Jun 17 '17 at 08:53