Asterisk-users Digest, Vol 167, Issue 17

Home » Asterisk Users » Asterisk-users Digest, Vol 167, Issue 17
Asterisk Users No Comments

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
To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] SHELL() function Asterisk 13 – can only accept one paramter in string?
Message-ID: <008fecea-e2c0-9230-7cb4-cd1b6990c4be@tootai.net>
Content-Type: text/plain; charset=utf-8; format=flowed

Le 27/07/2018 à 09:36, Stefan Viljoen a écrit :

[…]

*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