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.
Installation and Run CLI
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.
- Download the latest version of the cli.py from our Gitlab repository
Start CLI:Â In order to execute the CLI call your Python interpreter with the script name
user@laptop:~/prj/src$ python cli-SRAPS.py
Login to SRAPS
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.
Working with the CLI
The CLI provides a help command which can be used in two different ways:
- Print available commands
- Get command specific help
Listing available commands
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.
Managing redirections
The actions you can execute to manage redirections are the following:
Create a new redirection
- Delete a redirection
- Change the URL for a redirection for a specific phone
- Change the URL for a redirection for all phones redirecting to a specific URL (XXX)
- Check if a redirection for a specific phone exists
- Check if redirections for a list of phones exist (XXX)
- List the redirections you have setup
- by phone type
- by URL (XXX -> List all url)
- by phone type & URL
- all redirections
Create a new redirection - the add command
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.
Deleting a redirection - the remove command
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 redirections - the update command
Changing a redirection is a two-step process:
- Delete the old redirection
- Create a new redirection
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.
Checking redirection status - the check command
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
Listing active redirections - the list command
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}/ |
Using local variables
The CLI supports basic local variables allowing you to save some typing.
Setting a variable value
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}
Accessing variable values
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}
Showing variable values - the print command
You can use the print
 command to show the values of currently defined variables:
- print all shows all variable values
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).
Finishing your work
When you are done you can use the exit or logout command to exit the CLI.
Further Information
Related articles