Asterisk 1.8 pass variable between contexts

Please markup your dialplan using the </> markup tool on the forum. (The missing characters are the result of the forum treating the code as being marked up.)

Lecture is unreachable from Classt1! Are you really asking how to pass variables between channels? If that is the case you want GLOBAL or, possibly, SHARED.

IMPORT takes two parameters.

exten => s,n,Set(__Classpstt1)=105)

is incorrectly punctuated.

thanks for reply from experts.
I already spent few hours and tried maximum like GLOBAL, SHARED, _ , __, and others but still I can not see variable value passing . I tried latest version 17.x.

You’re not helping us help you.

Can you reply with a description of what you are trying to accomplish?

For example, “I want to create a system where my students can call in, listen to pre-recorded lectures and then in a subsequent call take a quiz to test their comprehension.”

You’re focusing on a single concept that doesn’t exist (“transfer variable value from one context to second context”) when that concept may not be the best way to accomplish your goal.

You’ve posted a couple of lines from 2 contexts of your dialplan that have no connection to each other. Does a call start in ‘class1?’ How does a call get to ‘Lecture?’

You’ve been asked for a more complete dialplan snippet, enclosed in preformatted text tags. It should cover from ‘answer()’ to ‘hangup()’ unless there is boatloads of stuff that is not relevant. It should look something like:

[class1]
        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       answer()
        same = n,                       set(Classp1=/tmp/classes/Class1/)
        same = n,                       set(Classps1=${Classp1}/books/hindi/)
        same = n,                       set(Classpstt1=105)
        same = n,                       goto(Lecture,s,1)
        same = n,                       hangup()

[Lecture]
        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       playback(${Classps1}/${Classpstt1})
        same = n,                       hangup()

You’ve been asked for a complete call log, enclosed in preformatted
text tags. It should look something like:

    -- Executing [s@class1:1] Verbose("SIP/poly-77a1-000000aa", "1,[s@class1]") in new stack
 [s@class1]
    -- Executing [s@class1:2] Answer("SIP/poly-77a1-000000aa", "") in new stack
    -- Executing [s@class1:3] Set("SIP/poly-77a1-000000aa", "Classp1=/tmp/classes/Class1/") in new stack
    -- Executing [s@class1:4] Set("SIP/poly-77a1-000000aa", "Classps1=/tmp/classes/Class1//books/hindi/") in new stack
    -- Executing [s@class1:5] Set("SIP/poly-77a1-000000aa", "Classpstt1=105") in new stack
    -- Executing [s@class1:6] Goto("SIP/poly-77a1-000000aa", "Lecture,s,1") in new stack
    -- Goto (Lecture,s,1)
    -- Executing [s@Lecture:1] Verbose("SIP/poly-77a1-000000aa", "1,[s@Lecture]") in new stack
 [s@Lecture]
    -- Executing [s@Lecture:2] Playback("SIP/poly-77a1-000000aa", "/tmp/classes/Class1//books/hindi//105") in new stack
    -- <SIP/poly-77a1-000000aa> Playing '/tmp/classes/Class1//books/hindi//105.slin' (language 'en')
       > 0x691a4468 -- Strict RTP learning complete - Locking on source address 192.168.0.139:2228
    -- Executing [s@Lecture:3] Hangup("SIP/poly-77a1-000000aa", "") in new stack
  == Spawn extension (Lecture, s, 3) exited non-zero on 'SIP/poly-77a1-000000aa'

We’re willing to help, you just have to give us something to work with :slight_smile:

Just for S & G, compare the number of replies to most topics. Most are ‘single digit.’ We’re at the 23rd post and we still don’t have a clear idea of what you’re trying to do.

I forgot to mention that you should set verbosity to 3 or more ('core set verbose 3') when collecting a console log sample.

Hello team, thanks for your support. its appreciable.

My question was related to fetch variable value from one context to second context, I tried SetGlobalVar or GLOBAL and others but I don’t get solution yet, seems I was illogically thinking.

When I used like goto(Lecture,s,1), it is already working with variable value transferring.

I hope you understanding my issues.
I am new with asterisk and I am learning here.
thanks

Variables are only set when the context is used, if the context isn’t used then the variables won’t be set.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.