[英]How to execute FreeSwitch command using java code
我是freeswitch的新手,我已經嘗試從fs_cli控制台在freeswitch中使用origin命令,並且該命令工作正常。 現在我的要求是從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();
}
}
上面的問題得到解決:我用以下代碼段創建了一個.sh腳本:
#!/bin/bash
fs_cli -x "reloadxml"
echo "executed at : $(date)" >> /var/tmp/testlog.txt
並使用Java代碼執行此.sh文件。 而已。 我創建了一個testlog.txt文件來檢查天氣是否執行了fs_cli -x“ reloadxml”命令。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.