FreeSWITCH dialplan system and null strings

In a FreeSWITCH dialplan the application action system is used to execute system e.g. shell commands. You can also use the returned result from a system command to set a dialplan variable e.g.,

<action application="set" data="result=${system myscript.sh"/>

The problem is that if the system directive does not return a null terminated string then extra garbage can end up in the data variable in the dialplan.

So your shell script must explicitly terminate any strings in its output. Normally this won’t be a problem but if you are using piped results and awk then you can end up with no null.

In your awk print you must use printf as follows,

awk '{ printf "%s%c", $1, 0 }'

That will print your string (e.g. $1 field) and then print the number 0 as a character. This in effect fakes what is returned as a string that is null terminated.

Here is the FreeSWITCH wiki on the dialplan use,

http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_system

Here are some of my examples as used in custom feature codes,

http://www.openmutual.org/resources/freeswitch-custom-features/