[asterisk-users] How to access environment variable?
James Fromm
fromm at omnis.com
Tue Feb 6 12:59:18 MST 2007
How do you start Asterisk? You need to make sure the environment
variable you want inside Asterisk is being exported. I use 'export
HOSTNAME' in my asterisk init script and it works like a charm.
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.
>
> However, at the CLI prompt:
> ! echo $PATH and ! echo $MYIP
> both work fine.
>
> Larry
>
>
> Ioan Indreias wrote:
>> Hello Larry,
>>
>> Probably your variable (MYIP) is not accessible to asterisk process
>> environment.
>> Test it with ${ENV(PATH)} and you will have a result there....
>>
>> exten => s,n,Set(test=${ENV(PATH)})
>> -- Executing Set("IAX2/test_iax",
>> "test=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin") in new stack
>>
>
>
> Larry Alkoff wrote:
> > How can I access an environmental variable in Asterisk 1.2.5?
> >
> > It should be possible according to:
> > http://www.voip-info.org/wiki/view/Asterisk+variables
> > which says:
> >
> > Environment Variables
> > You may access unix environment variables using the syntax:
> > ${ENV(foo)}
> > ${ENV(ASTERISK_PROMPT)}: the current Asterisk CLI prompt.
> > ${ENV(RECORDED_FILE)}: the filename of the last file saved by the
> Record command
> >
> >
> > I have an environmental variable MYIP which contains my current IP
> address but when I execute exten _4XX the following line only says
> > 'myip is ' and the rest is blank instead of showing
> > 'myip is www.xxx.yyy.zzz'
> >
> > exten => _4XX,n,VERBOSE("myip is ${ENV(MYIP)}")
> >
> > Why doesn't it work?
> >
> > Larry
>
More information about the asterisk-users
mailing list