[asterisk-users] SHELL() function Asterisk 13 - can only accept one paramter in string?

Stefan Viljoen viljoens at verishare.co.za
Fri Jul 27 06:57:27 CDT 2018

Hi Ludovic


Thank you very much for replying!


Ok, I’ll give up on the dialplan apps then in total and try out AGI.


Thanks again,



From: Ludovic Gasc <gmludo at gmail.com> 
Sent: Friday, 27 July 2018 13:37
To: viljoens at verishare.co.za; Asterisk Users Mailing List - Non-Commercial Discussion <asterisk-users at lists.digium.com>
Subject: Re: [asterisk-users] SHELL() function Asterisk 13 - can only accept one paramter in string?


Hi Stefan,


You might use AGI instead of SHELL, it's better because you can interact with the call via AGI and you don't have a risk of remote execution you might have if you add arguments that come from outside, for example via a SIP header.




Ludovic Gasc (GMLudo)



Le ven. 27 juil. 2018 à 09:37, Stefan Viljoen <viljoens at verishare.co.za <mailto:viljoens at verishare.co.za> > a écrit :

Hi all

This is a followup on my post "Asterisk 13 - system() dialplan app cannot call bash scripts" from yesterday

I've given up trying to use system() to call BASH scripts with parameters from Asterisk 13. 

Turned out under Asterisk 13.22.0 System() DOES work, but only if you do NOT attempt to pass any parameters to the called script.

This works, and reliably calls the script:

same=>n,System(/bin/bash /usr/src/bash/setData.sh)

However, the moment you do this:

same=>n,System(/bin/bash /usr/src/bash/setData.sh ${CHANNEL(accountcode)})

you get

WARNING[30982][C-00000238] app_system.c: Unable to execute '/usr/src/bash/setData.sh'

I therefore tried to use SHELL() to do what I was trying to do with SYSTEM().

This also does not work, as SHELL() apparently can only ever parse ONE asterisk parameter in the string sent to it. All the rest are sent as blank.

If I do this:

same=>n,Set(nothing=${SHELL(/usr/src/verdi/bash/verdiLogIncomingCall.sh NA 201807270838t49hgzs SIP/centra-out-00006d9a IN SIP/3027-00006db1 SIP/3027-00006db1 ApiLogIncomingCall.java 1)})

The script sees, on dialplan execution:

[root at acasterisk bash]# cat passed_param.txt <> &call_reference=201807270838t49hgzs&originating_channel_id=SIP/centra-out-00006d9a&direction=IN&requested_endpoint=SIP/3027-00006db1&caller_id=SIP/3027-00006db1&sourced_from=ApiLogIncomingCall.java&successfully_sent_to_server=1
[root at acasterisk bash]#

E. g. all params present - because no variable references need to be parsed.

If I use this:

exten=>s,1,NoOp(Entering Verdi answer macro - picked up by ${CHANNEL})
same=>n,NoOp(Source Channel: ${sourceChannel})
same=>n,NoOp(Answering Channel: ${CHANNEL})
same=>n,NoOp(Lodging CDR accountcode: ${curIncAccCode} as an incoming call from ${numbersource} with VerDi and answered by ${CHANNEL}...)
same=>n,Set(nothing=${SHELL(/usr/src/verdi/bash/verdiLogIncomingCall.sh NA ${curIncAccCode} ${sourceChannel} IN ${CHANNEL} ${numbersource} ApiLogIncomingCall.java 1)})

giving this on exection:

-- SIP/3002-000070c2 answered SIP/centra-out-000070bf
    -- Executing [s at macro-verdianswer:1] NoOp("SIP/3002-000070c2", "Entering Verdi answer macro - picked up by SIP/3002-000070c2") in new stack
    -- Executing [s at macro-verdianswer:2] NoOp("SIP/3002-000070c2", "Source Channel: SIP/centra-out-000070bf") in new stack
    -- Executing [s at macro-verdianswer:3] NoOp("SIP/3002-000070c2", "Answering Channel: SIP/3002-000070c2") in new stack
    -- Executing [s at macro-verdianswer:4] NoOp("SIP/3002-000070c2", "Lodging CDR accountcode: 2018072709061hrriyu
    --  as an incoming call from 27182941000 with VerDi and answered by SIP/3002-000070c2...") in new stack
    -- Executing [s at macro-verdianswer:7] Set("SIP/3002-000070c2", "nothing=Incoming call NOT stored. Contact software support.
    -- ") in new stack

e. g. my variables ARE populated, and if I NoOp them, they have values.

In this situation, the script called via SHELL() sees:

[root at acasterisk bash]# cat passed_param.txt <> &call_reference=2018072709061hrriyu&originating_channel_id=&direction=&requested_endpoint=&caller_id=&sourced_from=&successfully_sent_to_server=

E. g. SHELL() apparently only ever parses the FIRST Asterisk variable passed into it as a string, and never parses subsequent variable references.

Can anybody confirm or suggest a solution?

I desperately need to be able to execute external BASH scripts and pass multiple parameters to them, somehow. Nothing that worked in 1.8 for this works in 13...



-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20180727/3853e405/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 76340 bytes
Desc: not available
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20180727/3853e405/attachment-0001.png>

More information about the asterisk-users mailing list