Fs cli
From FreeSWITCH Wiki
Contents |
Introduction
The fs_cli program allows a user to connect to a running FreeSWITCH instance. The fs_cli program can connect to the FreeSWITCH process on the local machine or on a remote system. (Network connectivity to the remote system is, of course, required.) The fs_cli program uses FreeSWITCH's event socket to send commands issued by the user and to collect the server responses to send to the display. A C-based socket library, esl, was developed for use with fs_cli although a programmer could use this library for any C language program that needs to connect to the event socket. With the -x switch (see below) fs_cli can issue a command to the server, get a response, and then disconnect.
The fs_cli program can connect to FreeSWITCH whether it is running as a daemon or in console mode, regardless of operating system or if running in screen.
Install
- Make current
- cd libs/esl
- make
- ./fs_cli
Usage
Launching fs_cli
The usage for fs_cli is:
./fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [profile]
The command line arguments are:
- -H - Host name or IP address (default is 127.0.0.1)
- -P - TCP port number (default is "8021")
- -p - Logon password (default is "ClueCon")
- -d - Debug level 0-7 (default is 6, NOT the same as log level)
- -l - Log level level warn/info/debug (default is debug)
- -q - Disable logging
- -x - Command to execute, wrapped in quotes
- profile - Profile name from .fs_cli_conf file
While Connected
While connected the user can issue any command normally available on the FreeSWITCH command line. Additionally, there are several commands that can be issued using a forward slash (/) character. The following commands all disconnect from the FreeSWITCH command line:
- /quit
- /bye
- /exit
Other "slash" commands correspond to mod_event_socket commands:
- /event - Enable events (More Info)
- /noevents - Disable all events previously enabled with /event
- /nixevent - Enable all but one type of event (More Info)
- /log - set loglevel of the FreeSWITCH daemon (e.g. /log info or /log alert) (More Info)
- /nolog - Disable logging (More Info)
- /filter
- /help - List fs_cli commands
(TODO: document /filter command)
For command-line editing, see "Command-Line Editing" section of mod_console. The details are the same as of SVN r13964.
Configuration Options
An optional configuration file can be set up in the user's home directory. The file name is .fs_cli_conf. The config file uses a simple INI-style layout and allows for multiple profiles. This allows one to access many FreeSWITCH systems from a single workstation. A sample .fs_cli_conf file:
[default] ;overide any default options here loglevel => 6 [profile1] host => 192.168.1.10 port => 8021 password => secret_password debug => 7 [profile2] host => 192.168.1.11 port => 8021 password => someother_password loglevel => info
Usage Examples
Simple
./fs_cli
Launches fs_cli which connects to local machine using default username, password, and debug level.
With Profile
./fs_cli My_profile
Launches fs_cli using profile named "My_profile" found in .fs_cli_conf file.
Sending a command and then logging off
./fs_cli -x "sofia status profile internal"
Launches fs_cli and sends a command before logging off. The output of the above command looks like this:
./fs_cli -x "sofia status"
Name Type Data State
=================================================================================================
external profile sip:mod_sofia@71.6.70.229:5080 RUNNING (0)
example.com gateway sip:joeuser@example.com NOREG
internal profile sip:mod_sofia@192.168.50.229:5060 RUNNING (0)
192.168.50.229 alias internal ALIASED
internal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0)
default alias internal ALIASED
nat alias external ALIASED
outbound alias external ALIASED
=================================================================================================
3 profiles 4 aliases
TODO
- Option to see all output to include FS console output.
- Option to see all output from all fs_cli instances connected to the fs box, plus the console.
- Option to connect to more than one FS box.

