1

I am new to freeswitch, I have tried originate command in freeswitch from fs_cli console and it was working properly. now my requirement is to execute the same from a java application. 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();
}
}
  • Possible duplicate of [Execute external program in java](https://stackoverflow.com/questions/13991007/execute-external-program-in-java) – rkosegi Nov 04 '17 at 09:07

2 Answers2

0

You should use mod_esl.

There are java examples in conlfluence.

Also, I made example for spring boot + netty (for outbound mode)

Artyom Chernetsov
  • 1,394
  • 4
  • 17
  • 34
0

Above problem get resolved : I have created a .sh script with the bellow code snippet:

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

and execute this .sh file using java code. That's it. I have created a testlog.txt file to check weather the fs_cli -x "reloadxml" command is executed or not.

derHugo
  • 83,094
  • 9
  • 75
  • 115