Hi Daniel

Thanks for the reply!

Yes, turns out it was all my fault, I had a line feed character (0x0a a.k.a 
printf("\n")) in one of the Asterisk channel variables passed via system() / 
shell() to my target script.

It seems 13.22.0 (I'm using the same version as you) reacts to a line feed in 
the parameter string by not processing or parsing the string any further one 
the line feed is encountered.

I removed the line feed (by using "echo -n" instead of just "echo" in a related 
BASH script that was providing input to Asterisk also via SHELL) and the 
problem disappeared and system() (and shell() itself ) started working 
correctly.

So, the moral is just keep the data clean that is fed through SYSTEM() and 
SHELL() from having any line-feeds in them.

On Asterisk 1.8 (my previous version) line-feeds in an Asterisk channel 
variable dereferenced in a SYSTEM() or SHELL() call did NOT stop parsing of the 
rest of the string - so apparently a relevant difference between the two 
versions there.

Kind regards,
---
Message: 2
Date: Fri, 27 Jul 2018 10:24:56 +0200
From: Administrator TOOTAI <[email protected]>
To: [email protected]
Subject: Re: [asterisk-users] SHELL() function Asterisk 13 - can only
        accept one paramter in string?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed

Le 27/07/2018 à 09:36, Stefan Viljoen 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.

[...]

*CLI> core show version
Asterisk 13.22.0 built by root @ pabx on a x86_64 running Linux on
2018-07-14 13:36:49 UTC

This works for us

same = n,system(/bin/echo "To: ${CALLED_CHANNEL}   From: ${ORI_CALL}" | 
/usr/bin/mail -s "TOOTAiAudio - Congestion Gateway ${CONGESTION_GW} used" 
${AUDIO_ADMIN})

--
Daniel


-- 
_____________________________________________________________________
-- 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:
      https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to