bruce bruce
2010-Jun-19 14:58 UTC
[asterisk-users] Using SetVar with System() is it possible?
Hi Guys, 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? * * * * * *Thanks,* * * -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100619/990798de/attachment.htm
Steve Edwards
2010-Jun-19 15:56 UTC
[asterisk-users] Using SetVar with System() is it possible?
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?Really? Is posting questions showing you've made zero effort faster or easier than reading the help text or just trying it? ) 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. Wouldn't it faster for you to just try it? You might learn why it didn't work? The system() application is (IMO) a kludge. Sometimes it is the only way, but usually it is just the lazy way to solve a problem in an unreliable and inefficient way. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Tzafrir Cohen
2010-Jun-19 17:56 UTC
[asterisk-users] Using SetVar with System() is it possible?
On Sat, Jun 19, 2010 at 10:58:17AM -0400, bruce bruce wrote:> Hi Guys, > > 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)")*There's the function SHELL. Though I suspect you use 1.2 and I'm not sure if it was there already. Anyway, I'm the output of that command is so simple to parse. -- Tzafrir Cohen icq#16849755 jabber:tzafrir.cohen at xorcom.com +972-50-7952406 mailto:tzafrir.cohen at xorcom.com http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir