【问题标题】:How to execute FreeSwitch command using java code如何使用 java 代码执行 FreeSwitch 命令
【发布时间】:2017-11-04 08:50:53
【问题描述】:

我是 freeswitch 的新手,我尝试了从 fs_cli 控制台在 freeswitch 中发起的命令,它工作正常。现在我的要求是从 java 应用程序中执行相同的操作。我试过下面的代码。

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

【问题讨论】:

标签: java linux freeswitch


【解决方案1】:

你应该使用mod_esl

conlfluence中有java示例。

另外,我做了example for spring boot + netty(用于出站模式)

【讨论】:

    【解决方案2】:

    上述问题得到解决: 我用波纹管代码 sn-p 创建了一个 .sh 脚本:

    #!/bin/bash
    fs_cli -x "reloadxml"
    echo "executed at : $(date)" >> /var/tmp/testlog.txt
    

    并使用 java 代码执行这个 .sh 文件。就是这样。 我创建了一个 testlog.txt 文件来检查是否执行了 fs_cli -x "reloadxml" 命令。

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 1970-01-01
      • 2012-07-08
      • 1970-01-01
      • 1970-01-01
      • 2017-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多