[asterisk-users] How to access environment variable?

Yuan LIU yliu11 at hotmail.com
Tue Feb 6 21:31:30 MST 2007


>From: Larry Alkoff <labradley at mindspring.com>
>
>I was only trying to demonstrate that my special variable MYIP was indeed 
>in the environment of the shell.  I suspect it's not in the Asterisk 
>process environment - why I dunno.
>
>I'll look at that tomorrow but suspect I'll never be able to read the MYIP 
>variable from Asterisk.

Yes you are.

exten => 501,1,NoOp(${ENV(MYIP)})

$ sudo env MYIP=899 asterisk -gvvvc
*CLI> dial 501
    -- Executing NoOp("OSS/dsp", "899") in new stack

Yuan Liu

>Larry
>
>
>Tzafrir Cohen wrote:
>>On Tue, Feb 06, 2007 at 08:04:23AM -0600, Larry Alkoff wrote:
>>>Thanks for your reply Ioan.
>>>
>>>Very interesting.  ${ENV(PATH)} works to display the path
>>>but ${ENV(MYIP)} does not!
>>>
>>>There must be a list in Asterisk that only allows cerain environmental 
>>>variables to be shown.  A very unnecessary bummer.
>>>
>>
>>Right.
>>
>>>However, at the CLI prompt:
>>>! echo $PATH and  ! echo $MYIP
>>>both work fine.
>>
>>However This is incorrect: '!' only works in a remote asterisk terminal: a 
>>connection from a different process (on the same system) to the running
>>Asterisk process.
>>
>>It will run a subshell of thatremote process. So it is not necessarily
>>related to the environment of the Asterisk process.
>>
>>Also: when running something in System(), note that you run a
>>subprocess, and that this subprocess may have its own separate
>>environment.
>
>--
>Larry Alkoff N2LA - Austin TX
>Using Thunderbird on Linux




More information about the asterisk-users mailing list