Content
This CLI script provides an implementation of the XML-RPC interface, and allows the user to manage the redirections of his phones.
It is Open Source and given to the users - just like the underlying service - without any warranty whatsoever. Feel free to edit the script according to your requirements.
In order to use the Snom redirection service command line interface (CLI) you need to have Python installed. Python is preinstalled on many Linux distributions and on Mac OS X. However it is also available for all other major operating systems. You can find the current Python installation for your system here.
Start CLI: In order to execute the CLI call your Python interpreter with the script name
user@laptop:~/prj/src$ python cli-SRAPS.py
The CLI will ask for your SRAPS credentials. If you do not have yet a user account, you can sign up online at https://sraps.snom.com.
############################################### Snom Redirection Server Console Ver. 1.2.05-alpha (c) 2010-2018 snom technology AG ############################################### Username:
After a successful login the CLI will present the prompt:
YourUsername%>
with YourUsername being your personal SRAPS user name.
The CLI provides a help command which can be used in two different ways:
In order to list all available commands type:
YourUsername%> help
If you want to get a short description of the command, type help <command>:
Available commands (type help <command>): ========================================= add defaults help list remove update check exit history print set version e.g. YourUsername%> help list List phones configured in redirection service 'list all' list all phones 'list <phone_type>' list only phone matching <phone_type> (Eg. "list snom370") 'list <phone_type> <url>' list only phone matching thist <phone_type> and <url> (Eg. "list snom370 http://server.example.com/" )
The list of commands might change without further notice. Please check for new or updated commands on any script updates.
The actions you can execute to manage redirections are the following:
Create a new redirection
In order to create a new redirection for a given phone use the add command:
YourUsername%> add 000413401XXX https://www.snom.com/redirect.php?mac={mac} Adding redirection for 000413401XXX to https://www.snom.com/redirect.php?mac={mac}. Redirection to https://www.snom.com/redirect.php?mac={mac} for snom715 with MAC address 000413401D95 has been successfully registered.
In order to delete an existing redirection use the remove command:
YourUsername%> remove 000413401XXX Successfully removed redirection for snom715 with MAC address 000413401XXX.
The system will refuse to remove a redirection if it was not created with your username!!!
Changing a redirection is a two-step process:
Both steps are handled by the update command seamlessly.
Update the redirection for one phone
In order to update the redirection for one phone call the update command with the same syntax as the add command:
YourUsername%> update 000413401XXX https://www.snom.com Updating redirection for 000413401XXX to https://www.snom.com. Redirection to https://www.snom.com for snom715 with MAC address 000413401XXX has been successfully updated.
In order to check if a redirection for a given phone exists use the check
command.
YourUsername%> check 000413401XXX snom820 with MAC address 000413401XXX is registered. Current redirection target is: https://www.snom.com
In order to list your active redirections you can use the list command.
Listing all active redirections
Use list all to list all active redirections. Please note that this command takes a couple of seconds to execute as it needs to query all phone types.
YourUsernam%> list all Loading information ... ---------------------------------------------------------------------------------------------------------------------------------------- | MAC address | Company | URL | ---------------------------------------------------------------------------------------------------------------------------------------- | 000413284XXX | Snom Technology GmbH | https://myprovserver/sraps/{mac}/ |
The CLI supports basic local variables allowing you to save some typing.
In order to assign a variable value use the set
command:
set myurl https://www.some-long-server.com/even/longer/path/and_some_file_name.php?mac={mac}
After you have set a variable value you can use it in all commands:
add 000413123XXX %myurl
would be executed as
add 000413123XXX https://www.some-long-server.com/even/longer/path/and_some_file_name.php?mac={mac}
You can use the print
command to show the values of currently defined variables:
print var_name shows the value of the variable called var_name
YourUsername%> print all Local variables: ================ a = snom715 b = snom725 myurl = https://www.some-long-server.com/even/longer/path/and_some_file_name.php?mac={mac}
or
YourUsername%> print myurl myurl = https://www.some-long-server.com/even/longer/path/and_some_file_name.php?mac={mac}
As the % sign can also be used in URLs please choose your variable names wisely so they do not conflict with your URL. Like 20 is not a good variable name if your URL contains a whitespace (%20).
When you are done you can use the exit or logout command to exit the CLI.
Further Information
Related articles