Dialling a variable issue

Hi,

I am learning Asterisk using this guide: asteriskdocs.org/en/3rd_Edit … -book.html

I am now learning about global variables.

I have the following in my extensions.conf

[code][globals]
USER1=SIP/W8933X27

[LocalSets]
exten => 100,1,Dial(${USER1})[/code]

When I dial extension 100, it doesn’t go through and I have this in the logs

== Using SIP RTP CoS mark 5 -- Executing [100@LocalSets:1] Dial("SIP/W8933X27-0000000f", "") in new stack [Dec 26 00:17:48] WARNING[7810]: app_dial.c:2052 dial_exec_full: Dial requires an argument (technology/number) == Spawn extension (LocalSets, 100, 1) exited non-zero on 'SIP/W8933X27-0000000f'

The call goes through if I use this:

[code][globals]
USER1=SIP/W8933X27

[LocalSets]
exten => 100,1,Dial(SIP/W8933X27)[/code]

I can’t understand what I am missing. Please advise.

Thank you and happy holiday!

This will work for u

exten => 100,1,Dial(SIP/${EXTEN})

Hi,

If you are using Asterisk >= 1.4, you should use the GLOBAL() function to retrieve the variable content.

Hence,

[globals]
USER1=SIP/W8933X27

[LocalSets]
exten => 100,1,Dial(${GLOBAL(USER1)})

Regards,

Constantin

azhar117: ${EXTEN} is not a global variable. Internally it is not even really a variable. The fact that it works is irrelevant here.

constantinp: the GLOBAL function isn’t needed in 1.6.1.0. It might be needed for very old versions, and it may allow the value to be accessed when there is a conflicting local variable. It is needed when setting.

cometogether: There is nothing obviously wrong. The version of Asterisk may be relevant. My best guess is that you have two globals sections. If you want to continue a section, you must use this syntax:

globals

[quote=“david55”]
cometogether: There is nothing obviously wrong. The version of Asterisk may be relevant. My best guess is that you have two globals sections. If you want to continue a section, you must use this syntax:

globals[/quote]

That did it, there was a [globals] section further up. Thanks!