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

Stefan Viljoen viljoens at verishare.co.za
Fri Jul 27 02:36:09 CDT 2018

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
[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

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...



More information about the asterisk-users mailing list