背景介绍
opensips
的exec
模块用于执行外部命令,可以用于执行脚本,和上章介绍的kamailio
的exec
模块类似。
官方文档地址: exec,本次测试的opensips
版本是:
version: opensips 3.3.10 (x86_64/linux)
配置解析
|
|
重要函数
exec(command, [stdin], [stdout], [stderr], [envavp])
- command: 要执行的命令
- stdin: 输入参数,默认为空
- stdout: 输出参数,默认为空
- stderr: 错误输出参数,默认为空
- envavp: 环境变量,默认为空,环境变量名为:
OSIPS_EXEC_#
,#为环境变量的索引,从0开始。比如:OSIPS_EXEC_0
async(exec(command))
可以异步执行命令.
实战
- 配置文件:
|
|
-
输出结果:
syslog日志:
1 2
May 20 11:44:27 [1492] The output is / May 20 11:44:27 [1492] Received the following error:<null>