IceWarp Command Line Tool
There is a powerful command line tool which you can use to administer domains and accounts as well as all system variables.
This tool is called tool.exe (tool.sh in Linux) and can be found directly in the <InstallDirectory> folder.
It is easy to use and you only have to know the API constants. The complete list of API constants is in APIconst.pas file in the <InstallDirectory>\API\Delphi\ folder.
Please note that using tool.exe for performing large operations can cause temporary service unavailability because the service needs to be restarted for some changes in configuration.
For servers with many domains and many users with high loads, restarting can take some time. Therefore, we recommend performing large batches of changes in low-load periods.
The command line tool does not support multi-line – you can encounter this e.g. using the autoresponder variable.
Command |
Description |
CREATE |
Creates a new object. It is followed by a type (domain or account) and a list of variables and values you want to assign to these variables. |
DELETE |
Deletes an object. It is followed by a type (domain or account) and a unique name of an object you want to delete. |
MODIFY |
Modifies any variable (property) of an object. It is followed by a type of object and a list of variables and values you want to assign to these variables. |
DISPLAY |
Displays any variable (property) of an object. It is followed by a type of object (domain, account or system) and a list of variables you want to show. The result is generated with double-line feeds. |
EXPORT |
Does the same as the DISPLAY command but this command shows on the screen everything separated by a comma (CSV format). The result is generated without double-line feeds. |
FILE |
Calls file functions. It is followed by USERSTATISTICS and all its parameters (see below). |
Parameter |
Description |
ACCOUNT [variables] |
Address any account on the server. |
DOMAIN [variables] |
Address any domain on the server. |
SYSTEM [variables] |
Address any system variable such as c_version, c_name, etc. The list is also in APIConst.pas. |
BATCH batch file |
Allows you to run a batch file with a set of commands included. See the examples below. Batchfile is just a common text file with commands. Each is on a separate line. These commands must not include "tool" at the beginning. Just the commands and parameters. |
USERSTATISTICS fromdate todate filterstring outputfile |
Saves userstatistics between fromdate and todate to specified output file for all users that fulfill the condition of filterstring. fromdate,todate have yyyy/mm/dd format filterstring supports also asterisks and question marks to specify more accounts. If it does not contain @ symbol it is considered a domain name. outputfile If you do not specify an absolute path, it will be saved to <InstallDirectory> folder. |
How to create other types of accounts
To do this, you have to use u_type property. Its values are also written in APIConst.pas file. For example, a mailing list has 1 as the value of this property. So if I want to create a mailing list I will have to use this:
tool create account mailing@icewarpdemo.com u_type 1 m_owneraddress "admin@icewarpdemo.com"
Usage
tool create account new@icewarpdemo.com u_name "New Account" u_password "pass" u_accounttype 2
- It creates an account with New Account in the Full Name field and pass as a password.
tool display account new@icewarpdemo.com u_mailbox u_accounttype
- It shows the values of both variables u_mailbox and u_accounttype of new@icewarpdemo.com account.
tool delete domain oldone.net
- It deletes oldone.net domain from your server.
tool modify account *@icewarpdemo.com u_accounttype 2
- It changes all accounts in icewarpdemo.com to IMAP accounts.
tool file userstatistics 2004/12/25 2004/12/31 icewarpdemo.com statistics.txt
- It saves userstatistics between dates 2004/12/25 and 2004/12/31 for all accounts in icewarpdemo.com domain to statistics.txt file. This file can be found in <InstallDirectory> folder.
tool export domain * d_description d_postmaster
- It shows on the screen d_description and d_postmaster variables for all domains in CSV format - each value is separated by a comma.
tool export account *@* u_mailbox u_name u_password > accounts.txt
- Besides exporting the 3 above fields it also puts the user's full email address in the first column
tool import account contas.txt u_name u_password
- import the 3 fields from CSV
Please note that the first field imported from this CSV file is an email address – it is imported automatically and is not to be written in the import command. It has to be specified in CSV in the first place.
tool display system c_config_services_pop3_port
- It shows the system variable that contains a POP3 service port.
tool check account *@* passpolicy
- It verifies which accounts do not comply with the new password policy.
tool check account *@* passpolicy > <filename>
- It redirects to a file.
Example:
tool check account *@* passpolicy>outofpolicy.txt
tool display account @*@ > accounts.txt
- gets a listing of accounts with double line feeds
tool export account *@* > accounts.txt
- gets listing with single line feeds
--------------------------------------------------------------------------------------------------------------------
More information on how to use tool.exe / tool.sh is available directly in the command line.
IceWarp>tool tutorial
Quick tool tutorial:
####################
# Create a new domain doe.com
------------------------------
tool create domain doe.com d_description "Test domain"
# Create accounts using the name, pass and comment
-----------------------------------------------
tool create account john@doe.com u_name "John Doe" u_password "john_pass" u_co
mment "John's first test account"
tool create account alex@doe.com u_name "Alex Doe" u_password "alex_pass" u_co
mment "Second test account"
tool create account tom@doe.com u_name "Thomas Doe" u_password "tom_pass" u_co
mment "Third test account. Tom's first mail account."
# Display comments of all doe.com accounts
-------------------------------------------
tool display account "*@doe.com" domain u_comment
# Export all accounts of doe.com where the comment contains the word "first" to
file doe_com.csv using --filter option
-----------------------------------------
tool -filter="u_comment like '%first%'" export account "*@doe.com" u_name u_pa
ssword u_comment > doe_com_custom.csv
# Export all accounts of doe.com to csv file (base64 encoded)
-------------------------------------------------------------
tool export account "*@doe.com" u_backup > doe_com.csv
# Display comments of all doe.com accounts
-------------------------------------------
tool display account "*@doe.com" domain u_comment
# Delete all domain accounts
-----------------------------
tool delete account "*@doe.com"
# Import accounts from a file
------------------------------
tool import account "doe_com.cvs" u_name u_password u_comment
# Modify comment of all accounts @doe.com
------------------------------------------
tool modify account "*@doe.com" u_comment "Modified comment"
# Delete all accounts of doe.com domain and delete doe.com domain
-----------------------------------------------------------------
tool delete account "*@doe.com"
tool delete domain "doe.com"
More examples:
# Show some system variables
-----------------------------
tool display system c_system_services_smtp_port c_version c_configpath
# Change a system variable
-----------------------------
tool modify system c_as_general_enable 1
# Display some information
---------------------------
tool display service smtp st_runningtime st_serverout st_server
tool display userstatistics 2004/10/01 2004/10/31 "*"
tool display remoteaccount "*@icewarp.com" ra_server ra_username
# Create a remote account
-----------------------
tool create remoteaccount @doe.com ra_server server.name.com ra_username user_
name
# Display all domains on a remote server and their description
-----------------------------------------------------------
tool -remote="admin,adminspass,remote.server.com:32000" display domain "*" D_D
escription
# Display variables of an object
--------------------------------
tool search domain
# Create/drop tables for domains and accounts in SQLite DB
and force the server to use this DB
---------------------------------
tool create tables 0 D:\storage.db;;;;;3
tool delete tables 0 D:\storage.db;;;;;3
# Create/drop tables for groupware in SQLite DB
and force the server to use this DB
---------------------------------
tool create tables 2 D:\gw.db;;;;;3
tool delete tables 2 D:\gw.db;;;;;3
# Convert account storage to database
-------------------------------------
tool set storage 1
# Convert account storage to filesystem
---------------------------------------
tool set storage 0
# Backup settings (the same action as "File/Backup Settings"
in Administration Console)
----------------------------
tool export backup c:\temp\mybackupfile.zip
# Restore settings (the same action as "File/Restore Settings"
in Administration Console)
----------------------------
tool import backup c:\temp\mybackupfile.zip
Comments
0 comments
Article is closed for comments.