[英]How to execute FreeSwitch command using java code
I am new to freeswitch, I have tried originate command in freeswitch from fs_cli console and it was working properly. 我是freeswitch的新手,我已经尝试从fs_cli控制台在freeswitch中使用origin命令,并且该命令工作正常。 now my requirement is to execute the same from a java application.
现在我的要求是从Java应用程序执行相同的操作。 I have tried following code.
我试过下面的代码。
package org.freeswitch.esl.client.outbound.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Call {
Call() throws IOException {
Process pr = Runtime.getRuntime().exec("fs_cli -x reloadxml");
BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String str = null;
while ((str = br.readLine()) != null) {
System.out.println(str);
}
System.out.print("success");
}
public static void main(String[] args) throws IOException {
Call call;
call = new Call();
}
}
You should use mod_esl . 您应该使用mod_esl 。
There are java examples in conlfluence. 有一些Java示例可以融合在一起。
Also, I made example for spring boot + netty (for outbound mode) 另外,我还为spring boot + netty (用于出站模式)制作了示例
Above problem get resolved : I have created a .sh script with the bellow code snippet: 上面的问题得到解决:我用以下代码段创建了一个.sh脚本:
#!/bin/bash
fs_cli -x "reloadxml"
echo "executed at : $(date)" >> /var/tmp/testlog.txt
and execute this .sh file using java code. 并使用Java代码执行此.sh文件。 That's it.
而已。 I have created a testlog.txt file to check weather the fs_cli -x "reloadxml" command is executed or not.
我创建了一个testlog.txt文件来检查天气是否执行了fs_cli -x“ reloadxml”命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.