[asterisk-users] Using SetVar with System() is it possible?

Leif Madsen leif.madsen at asteriskdocs.org
Thu Jun 24 09:23:27 CDT 2010


Steve Edwards wrote:
> On Sat, 19 Jun 2010, bruce bruce wrote:
> 
>> Is it possible to harvest the output of system into a SetVar(variable)?
>>
>> exten => s,n,SetVar(var=system(asterisk -rx "sip show channels" | grep 
>> -c "(ulaw)")
>>
>> ??? any problem with the syntax?
> 
> ) Your parentheses don't match.
> 
> ) You didn't read the documentation that says system() returns FAILURE or 
> SUCCESS.
> 
> ) You didn't notice that setvar() is deprecated.
> 
> ) You didn't read the documentation that says set[var]() sets a name to a 
> value -- no mention of evaluating an application.

And you can't return the output of a dialplan application within another 
application -- that's what functions are for.

With 1.6.0 and later, you have the SHELL() function which allows you to do what 
you're trying to do:

exten => s,n,Set(RESULT=${SHELL(...)})

As mentioned by Steve, it would be trivial to find out what was wrong with your 
syntax if you had tested it in your development environment.

Leif.



More information about the asterisk-users mailing list