0
votes

This was working fine in Asterisk 1.8.32.3 - I'm testing with Asterisk 13.22.0 on Centos 7 running as root (already - as you'll see below):

same=>n,System(/usr/src/bash/setData.sh ${CHANNEL(accountcode)})

The script's permissions:

[root@localhost bash]# ls -l
-rwxr-xr-x 1 root root 1493 Jan 20  2016 setData.sh 
[root@localhost bash]# pwd 
/usr/src/bash
[root@localhost bash]#

I've upgraded to Asterisk 13, and Asterisk is now incapable of executing the setData.sh script:

[Jul 25 10:33:21] WARNING[30982][C-00000238] app_system.c: Unable to execute '/usr/src/bash/setData.sh'

I've looked at numerous posts about this, but none are applicable or end blind with no solution.

I've tried running asterisk as root, no luck - see above.

I've set permissions on the script to executable by everybody, not working.

I've changed the dialplan code to

same=>n,System(/bin/bash /usr/src/bash/setData.sh ${CHANNEL(accountcode)})

also no effect.

I've also tried completely disabling / deactivating SELinux in Centos 7 - no effect, error persists.

If you run the script from the shell / xterm, it works correctly.

How does one get Asterisk 13 to execute a simple BASH script via the System() dialplan application as worked in previous Asterisk versions such as 1.6 and 1.8?

Thanks!

Stefan

2
I suggest you run this under strace so that you can see the exact underlying OS error message.cdarke

2 Answers

1
votes

Ok this is resolved.

Turns out that the problem is that one of the parameters I tried to pass through the SYSTEM() and SHELL() calls in my dialplan, contained a linefeed character (\n, or hex 0x0a).

It appears that in Asterisk 13.22.0, in a call to SYSTEM() or SHELL(), parsing and evaluation of Asterisk channel variables passed into SYSTEM() or SHELL() STOPS when a linefeed (\n) character is hit.

Once I cleaned up the variables (removing the \n one variable contained, originated from a UUID I was generating) and all variables' contents passed to the SYSTEM() dialplan application were "clean" - without any \n characters - the SYSTEM() dialplan application started functioning normally and started calling my BASH script with paramters with Asterisk channel variable values, as intended.

No changes to my dialplan, but in a bash script I was running to get the UUID (via a CURL to a Java application) I had this:

echo $uuid

and all I had to do was this:

echo -n $uuid

The moment that was done and the UUID without the trailing linefeed was fed to SYSTEM() in my dialplan on Asterisk 13.22.0, SYSTEM() started working and everything was functional.

0
votes

1) check selinux

2) try run under same user as you pbx(see asterisk.conf)

if not help, stop asterisk, start asterisk in console mode

asterisk -vvvgc

see error