<div dir="ltr">Hi Stefan,<div><br></div><div>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.</div><div><br></div><div>Regards.<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr">--<br><div style="font-size:small"><div>Ludovic Gasc (GMLudo)</div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">Le ven. 27 juil. 2018 à 09:37, Stefan Viljoen <<a href="mailto:viljoens@verishare.co.za">viljoens@verishare.co.za</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all<br>
<br>
This is a followup on my post "Asterisk 13 - system() dialplan app cannot call bash scripts" from yesterday<br>
<br>
I've given up trying to use system() to call BASH scripts with parameters from Asterisk 13. <br>
<br>
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.<br>
<br>
This works, and reliably calls the script:<br>
<br>
same=>n,System(/bin/bash /usr/src/bash/setData.sh)<br>
<br>
However, the moment you do this:<br>
<br>
same=>n,System(/bin/bash /usr/src/bash/setData.sh ${CHANNEL(accountcode)})<br>
<br>
you get<br>
<br>
WARNING[30982][C-00000238] app_system.c: Unable to execute '/usr/src/bash/setData.sh'<br>
<br>
I therefore tried to use SHELL() to do what I was trying to do with SYSTEM().<br>
<br>
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.<br>
<br>
If I do this:<br>
<br>
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)})<br>
<br>
The script sees, on dialplan execution:<br>
<br>
[root@acasterisk bash]# cat passed_param.txt<br>
<a href="http://127.0.0.1/api/logIncomingCall?account_reference=NA&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" rel="noreferrer" target="_blank">http://127.0.0.1/api/logIncomingCall?account_reference=NA&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</a><br>
[root@acasterisk bash]#<br>
<br>
E. g. all params present - because no variable references need to be parsed.<br>
<br>
If I use this:<br>
<br>
[macro-verdianswer]<br>
exten=>s,1,NoOp(Entering Verdi answer macro - picked up by ${CHANNEL})<br>
same=>n,NoOp(Source Channel: ${sourceChannel})<br>
same=>n,NoOp(Answering Channel: ${CHANNEL})<br>
same=>n,NoOp(Lodging CDR accountcode: ${curIncAccCode} as an incoming call from ${numbersource} with VerDi and answered by ${CHANNEL}...)<br>
same=>n,Set(CHANNEL(accountcode)=${curIncAccCode})<br>
same=>n,Set(nothing=${SHELL(/usr/src/verdi/bash/verdiLogIncomingCall.sh NA ${curIncAccCode} ${sourceChannel} IN ${CHANNEL} ${numbersource} ApiLogIncomingCall.java 1)})<br>
same=>n,MacroExit()<br>
<br>
giving this on exection:<br>
<br>
-- SIP/3002-000070c2 answered SIP/centra-out-000070bf<br>
    -- Executing [s@macro-verdianswer:1] NoOp("SIP/3002-000070c2", "Entering Verdi answer macro - picked up by SIP/3002-000070c2") in new stack<br>
    -- Executing [s@macro-verdianswer:2] NoOp("SIP/3002-000070c2", "Source Channel: SIP/centra-out-000070bf") in new stack<br>
    -- Executing [s@macro-verdianswer:3] NoOp("SIP/3002-000070c2", "Answering Channel: SIP/3002-000070c2") in new stack<br>
    -- Executing [s@macro-verdianswer:4] NoOp("SIP/3002-000070c2", "Lodging CDR accountcode: 2018072709061hrriyu<br>
    --  as an incoming call from 27182941000 with VerDi and answered by SIP/3002-000070c2...") in new stack<br>
    -- Executing [s@macro-verdianswer:7] Set("SIP/3002-000070c2", "nothing=Incoming call NOT stored. Contact software support.<br>
    -- ") in new stack<br>
<br>
e. g. my variables ARE populated, and if I NoOp them, they have values.<br>
<br>
In this situation, the script called via SHELL() sees:<br>
<br>
[root@acasterisk bash]# cat passed_param.txt<br>
<a href="http://127.0.0.1/api/logIncomingCall?account_reference=NA&call_reference=2018072709061hrriyu&originating_channel_id=&direction=&requested_endpoint=&caller_id=&sourced_from=&successfully_sent_to_server=" rel="noreferrer" target="_blank">http://127.0.0.1/api/logIncomingCall?account_reference=NA&call_reference=2018072709061hrriyu&originating_channel_id=&direction=&requested_endpoint=&caller_id=&sourced_from=&successfully_sent_to_server=</a><br>
<br>
E. g. SHELL() apparently only ever parses the FIRST Asterisk variable passed into it as a string, and never parses subsequent variable references.<br>
<br>
Can anybody confirm or suggest a solution?<br>
<br>
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...<br>
<br>
Thanks!<br>
<br>
Stefan<br>
<br>
<br>
-- <br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
Check out the new Asterisk community forum at: <a href="https://community.asterisk.org/" rel="noreferrer" target="_blank">https://community.asterisk.org/</a><br>
<br>
New to Asterisk? Start here:<br>
      <a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki/display/AST/Getting+Started</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" rel="noreferrer" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a></blockquote></div>