Variables Are Empty After Redirecting A Channel

Home » Asterisk Users » Variables Are Empty After Redirecting A Channel
Asterisk Users 3 Comments

Guys,

I am using Asterisk 1.8.20.0 built by mockbuild @ buildvm-24.phx2.fedoraproject.org on a x86_64 running Linux on 2013-01-18 19:52:25 UTC

How can I set variable in one context and then Redirect a channel to another context and use variable there? The code below doesn’t work, so I’ve got empty VAR1 in context_2

[context_1]

exten => s,1,SET(__VAR1=VALUE1)
exten => s,n,ChannelRedirect(${CHANNEL},context_2,AMD,1)

[context_2]

exten => AMD,1,NoOp(VAR1: ${VAR1})

Thank you in advance, Igor

3 thoughts on - Variables Are Empty After Redirecting A Channel

  • You should be using Goto here instead of ChannelRedirect, since you are redirecting the channel which is executing ChannelRedirect (that slightly made my head hurt). Switching should also make the variable work as you desire.

    Cheers,

  • Sorry there is a mistake, actually I don’t redirect executing channel:

    exten => s,n,ChannelRedirect(${CHANNEL_TO_REDIRECT},context_2,AMD,1)

    I can’t use Goto because the ${CHANNEL_TO_REDIRECT} is active channel and Goto drops (hangs-up) it.

    So is there a way to pass variable to the target context after ChannelRedirect?

    Thanks, Igor