本文介绍了星号13-system()Dialplan应用程序无法在文件系统上调用bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在Asterisk 1.8.32.3中运行良好-我正在以root用户身份在Centos 7上使用Asterisk 13.22.0进行测试(已经-如下所示):

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)})

脚本的权限:

[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]#

我已经升级到Asterisk 13,而Asterisk现在无法执行setData.sh脚本:

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.

我曾尝试以root身份运行星号,但不走运-见上文.

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)})

也没有效果.

我还尝试了在Centos 7中完全禁用/禁用SELinux-无效,错误仍然存​​在.

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

如果从shell/xterm运行脚本,则脚本可以正常工作.

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

如何像以前的Asterisk版本(例如1.6和1.8)一样,使Asterisk 13通过System()拨号计划应用程序执行简单的BASH脚本?

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?

谢谢!

Stefan

推荐答案

确定.

事实证明,问题是我试图通过拨号计划中的SYSTEM()和SHELL()调用传递的参数之一包含换行符(\ n或十六进制0x0a).

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).

在Asterisk 13.22.0中,似乎在对SYSTEM()或SHELL()的调用中,当换行(\ n)字符为命中.

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.

一旦我清理了变量(删除了\ n一个包含的变量,该变量源自我正在生成的UUID),并且所有传递给SYSTEM()拨号计划应用程序的变量的内容都是干净的"-没有任何\ n字符- SYSTEM()拨号计划应用程序开始正常运行,并按预期使用带有Asterisk通道变量值的参数调用我的BASH脚本.

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.

我的拨号计划没有任何变化,但是在bash脚本中,我正在运行以获取UUID(通过CURL到Java应用程序)

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

我要做的就是这个:

echo -n $uuid

完成这一刻并将没有尾随换行符的UUID馈入我在Asterisk 13.22.0上的拨号计划中的SYSTEM(),SYSTEM()开始工作,一切正常.

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.

这篇关于星号13-system()Dialplan应用程序无法在文件系统上调用bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 05:29