Men & Mice Command Line Interface (CLI)
=======================================
The Men & Mice Command Line Interface (CLI) contains various commands to help you manage your network address space from the command line.

You can use the CLI interactively, executing one command at a time, or you can run script files to execute multiple commands in one batch.  Script files can be supplied as arguments when starting the CLI and they can be run from within the CLI using the execute command.

This document contains a list of the commands supported by the CLI and an example script to help you get started.


-----------------------------
Men & Mice CLI commands
-----------------------------
Below you will find a list of the commands and a description of each command.
When a command is executed, no value is returned unless explicitly stated in the command description.  However, if an error occurs while executing a command, an error number and an error string are returned.

The Men & Mice CLI supports several startup arguments.  To see those arguments, enter mmcmd -h.

Command List
------------
#                 Remark.
add               Adds a record to a zone.
addDevice         Adds a device to the enclosing IP range.
addDHCPServer     Adds a DHCP server to the list of known DHCP servers.
addIPRange        Adds an IP range.
addScope          Adds a scope to a DHCP server.
addServer         Adds a name server to the list of known name servers.
addSlaveZone      Adds a slave zone to a server.
addZone           Adds a zone to a list of servers.
backup            Creates a backup of the Men & Mice Central database.
close             Closes a zone without saving changes.
closeAll          Closes all zones without saving changes.
defaultTTL        Gets or sets the default TTL for a zone.
delete            Deletes a record in a zone.
deleteZone        Deletes a zone.
delRec            Deletes a record in a zone.
DHCPServer        Perform various actions on DHCP servers.
DHCPServers       Lists all available DHCP servers.
disable           Disables a record in a zone.
echo              Echoes text to current output.
edit              Changes a record in a zone.
enable            Enables a record in a zone.
execute           Executes a script file.
export            Exports a zone to an external file.
findRec           Finds a record in a zone.
help              Prints out help information.
history           Queries the history log.
import            Imports a zone from an external file.
ipRanges          Lists all available IP ranges.
isConnected       Returns true if we are connected to Men & Mice Central.
listHosts         Lists all hosts in an IP range.
login             Logs on to Men & Mice Central.
modifyDevice      Modifies a device.
modifyIPRange     Modifies an IP range.
modifyZoneOptions Modifies options for a zone.
open              Opens a zone.
print             Prints out one or more record from a zone.
prompt            Changes the prompting mode.
quit              Quits the program.
refresh           Reloads a zone from a server.
reloadZones       Reloads the list of zones from a server.
rem               Remark.
removeDevice      Removes a device.
removeDHCPServer  Removes a DHCP server from the list of known DHCP servers.
removeIPRange     Removes an IP range.
removeScope       Removes a scope from a DHCP server.
removeServer      Removes a server from the list of known servers.
revert            Reverts a DNS event.
save              Saves a zone.
sendMessage       Sends a message to all Men & Mice Consoles
scope             Perform various actions on DHCP scopes.
scopes            Lists DHCP scopes.
serverInfo        Lists information about a server.
servers           Lists all available servers.
sleep             Sleeps for specified number of seconds.
verify            Syntax checks a zone.
version           Returns the version number of the program.
who               Returns a list of users that are logged in.
zonehistory       Queries the history log (same as the 'history' command).
zoneInfo          Lists information about a zone.
zoneModified      Returns indication of whether a zone has been modified.
zoneOptions       Returns options for a zone.
zones             Lists all available zones.


Command Descriptions
-------------------
Below you will find a description of every command supported by the CLI.  Note that in many commands you can use a hyphen (-) instead of <zonename> to specify the last zone used.  For example, close - will close the last zone you worked with. If more then one zone with the same name are available you might need to refer to it directly by specifying the server name and the view in which it is located. The format is <server name>:<view name>:<zone name>. When printing out a zone called azone.com on server mainserv, you would use the command:
print mainserv::azone.com.
If this is the only known zone named azone.com, you can simply enter:
print azone.com.


add <zonename> <recno> <record>
Adds a record to a zone.  Providing <recno> as -1 adds the record at the end of the zone.

addDevice <address> n=<name> [<CFx>=<value>]*
Adds a device to the enclosing IP range. The IP Address <address> is locked for use in DNS.  You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.

addDHCPServer <server> [<proxy>] type=(MS|ISC|IOS) [user=<value>] [password=<value>] [<CFx>=<value>]*
Adds a DHCP server to the list of known servers. The user and password parameters are only used for Cisco IOS servers

addIPRange <IP range> name=<name> [subnet=t/f] [locked=t/f] [autoassign=t/f] [sc=<save comment>] [<CFx>=<value>]*
Adds an IP range. The range address <range address> can be in one of the following formats:
	1.2.3.0/24
	1.2.3/24
	1.2.3.1-1.2.3.2
	1.2.3.0 mask 255.255.255.0
You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.
Example: addIPRange Internal 10.10.10.0/24 -subnet comment=Internal range

addScope <subnet> <server> <title> [c=<comment>] [sc=<save comment>] [<CFx>=<value>]*
Adds a scope to a DHCP server.  You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.

addServer <server> [<address>] [<CFx>=<value>]*
Adds a name server to the list of known servers.  You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.

addSlaveZone <zonename> <server> <master address>+ 
Adds a slave zone to a server. There must be at least one master IP address.

addZone [-DS] <zonename> <server> [* | <slave>+] [<CFx>=<value>]*
Adds a zone to a list of servers. The -DS argument specifies that the zone created should be an Active Directory zone. Slave servers are optional more than one can be specified.  An asterisk (*) can be used instead of explicitly specifying slave servers.  If the asterisk is used, a slave zone will be created on all servers besides the master server.  You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.

backup [-f] [<path>]
Creates a backup of the Men & Mice Central database.  If no pathname is specified, the backup file will be created in the Men & Mice Central data directory. If a backup file already exists and the -f argument is not provided the command will fail with an error.

close <zonename>
Closes a zone without saving changes.

closeAll
Closes all zones without saving changes.

defaultTTL <zonename> [<value>]
Gets or sets the default TTL for a zone. If no value is provided the command returns the current TTL value.  Note: This command will only work for static zones on BIND servers.

delete <zonename> <recno>
Deletes a record in a zone.

deleteZone <zonename> [<server>+]
Deletes a zone. You can specify more then one server from which to remove the zone.  If no servers are provided the zone will be removed from all servers.

delRec <zonename> <recname> <rectype> <recdata>
Deletes all records that match <recname>, <rectype> and <recdata> from the zone <zonename>. Instead of <recdata> you can specify a wildcard * that will match all data values.

DHCPServer <ServerAddress> <command>
Perform various actions on DHCP servers. The following commands are supported:
	show optionvalue [all] 
		- Show DHCP server options 
	set optionvalue [sc=<savecomment>] [<field1>=<value1>] [<value2>]* 
		- Set DHCP server option
	delete optionvalue <OptCode> 
		- Delete DHCP server option
	show properties [all] 
		- Show DHCP server properties
	set property [sc=<savecomment>] [<field1>=<value1>] [<field2>=<value2>]*  
		- set DHCP server properties.


DHCPServers
Lists all available DHCP servers.

disable <zonename> <recno>
Disables a record in a zone.

echo <text>
Echoes <text> to current output.

edit <zonename> <recno> <record>
Changes the contents of record <recno>. The new record must be of the same type as the old one.

enable <zonename> <recno>
Enables a record in a zone.

export [-aging] <zonename> <filename>
Exports a zone to an external file. -aging argument specifies that if this is a Windows zone that has scavenging active the zone file will contain the aging values for each record.

findRec <zonename> <recname> <rectype> <recdata>
Finds all records that match <recname>, <rectype> and <recdata> from the zone <zonename>. Instead of <recdata> you can specify a wildcard * that will match all data values.

help [<command>]
Prints out help information.  If a command name is provided as an argument, detailed information about that command will be displayed.

history [zone=<zonename>] [user=<username>] [fmt=(ymd|dmy|mdy)] [from=<fromdate>] [to=<todate>] [data=<text>] [limit=n]
Queries the history log. You can filter the results by zone name, user name, data and a date range. You can also use the limit parameter to specify the maximum number of entries to return (the default limit is 1000 entries).

import [-DS] [-aging] <zonename> <server> [ * | <slave>+ ] <filename>
Imports a zone from an external file. The -DS argument specifies that the zone created should be an Active Directory zone. The -aging argument specifies that if this zone is created on a Microsoft Windows server and <filename> is a zone file that contains aging values for records, those values will be honored when the zone is created.

ipRanges [-d] [-e] <filter>*
Lists all available IP ranges. If the -d argument is specified, detailed information is displayed. If the -e argument is specified all ranges are displayed using the <from>-<to> format.  The filters can be one or more specifying names of a label and values of a custom property. The format of the filter is: [<label>:<value>]. Example: [Responsible Person:Joe]

isConnected
Returns true if we are connected to a Men & Mice Central server.

listHosts [-f] <IP range>
Lists all host in an IP range.  If the range contains more then 4096 IP addresses and -f is not provided the command will warn the user and ask whether it should continue.  The IP range can be in one of the following formats:
	1.2.3.0/24
	1.2.3/24
	1.2.3.1-1.2.3.2
	1.2.3.0 mask 255.255.255.0

login <server> <username> [<password>]
Logs on to the Men & Mice Central server.  If <password> is omitted, you will be prompted for the password.

modifyDevice <address> [n=<name>] [<CFx>=<value>]*
Modifies a device. You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner.

modifyIPRange <IP range> [subnet=t/f] [locked=t/f] [autoassign=t/f] [sc=<save comment>] [<CFx>=<value>]*
Modifies an IP range. You can set a custom property by the name of <CFx> to the value <value>.  More than one custom property value can be defined in this manner. The range address <range address> can be in one of the following formats:	
	1.2.3.0/24
	1.2.3/24
	1.2.3.1-1.2.3.2
	1.2.3.0 mask 255.255.255.0
Example: modifyIPRange  10.10.10.0/24 locked=t

modifyZoneOptions <zonename> [allow-xfer=all|none|ns|<servers>] [notify=all|none|<servers>]
Modifies options for a master zone on a Windows DNS Server.  The <servers> argument is a comma separated list of IP addresses.  Note: This command is not supported on the Windows 2000 DNS Server.

open <zonename>
Opens and reads a zone from server.

print [-l] <zonename> [<range>]
Prints out a zone. <range> is optional and can be on the form <num>[-<num>]. If the -l argument is specified line number are printed along with each record.

prompt [on/off]
Changes the prompting mode.  With prompting on, the user is questioned about all drastic changes he is about to make. With prompting off, the user is never prompted. If no argument is given, the program prints out whether prompting is on or off.

quit
Quits the program.

refresh [<zonename>]
Reloads a zone from a server. If no zone is specified then the list of known zones and servers is refresh.

reloadZones [<server>]
Reloads the list of zones from a server. If no server is specified then the list of zones is reloaded from all servers. This command differs from refresh in that it forces all server configurations to be re-read.

rem
A remark. The rest of the line is ignored.  The # character can also be used to indicate a remark.

removeDevice <address>
Removes a device.

removeDHCPServer <server> [sc=<save comment>]
Removes a DHCP server from the list of known servers.

removeIPRange <IP range> [sc=<save comment>]
Removes an IP range. The IP range can be in one of the following formats:
	1.2.3.0/24
	1.2.3/24
	1.2.3.1-1.2.3.2
	1.2.3.0 mask 255.255.255.0

removeScope <ScopeAddress> [server=<ServerAddress>] [sc=<savecomment>]
Removes a scope from a DHCP server.

removeServer <servername>
Removes a server from the list of known servers.

revert <EventItem ID>+
Reverts a DNS event. You can specify more then one ID of events to be reverted.

save <zonename> [<comment>]
Save changes done to a zone. 

sendMessage <message>
Sends a message to all Men & Mice Consoles. You must have administrator privileges to be able to send a message.

scope <ScopeAddress> <command>
Perform various actions on DHCP scopes. The following commands are supported:
   enable [server=<ServerAddress>]                                           ; Enable a scope on a DHCP server.
   disable [server=<ServerAddress>]                                          ; Disable a scope on a DHCP server.
   show reservedip                                                           ; Displays all reservations in a scope.
   show excluderange                                                         ; Displays all excluded ranges in a DHCP scope.
   show iprange                                                              ; Displays all address pools in a DHCP scope.
   show clients                                                              ; Displays all clients in a DHCP scope.
   show properties                                                           ; Displays properties and custom properties of a DHCP scope.
   <ServerAddress> add excluderange <StartIP> <EndIP> [sc=<savecomment>]     ; Adds an excluded range to a DHCP scope.
   <ServerAddress> delete excluderange <StartIP> <EndIP> [sc=<savecomment>]  ; Deletes an exclude range from a DHCP scope.
   <ServerAddress> add iprange <StartIP> <EndIP> [sc=<savecomment>]          ; Adds an address pool to a DHCP scope.
   <ServerAddress> delete iprange <StartIP> <EndIP> [sc=<savecomment>]       ; Deletes an address pool from a DHCP scope.
   add reservedip <ReservedIP> <MAC_Address> n=<ClientName>                  ; Adds a reservation to a DHCP scope.
     [c=<ClientComment>] [t=<ClientType>(DHCP | BOOTP | BOTH)]               ; The c=<ClientComment> argument is for MS DHCP only
     [d=<DDNSHostName>] [sc=<savecomment>]
   delete reservedip <ReservedIP> <MAC_address> [sc=<savecomment>]           ; Deletes a reservation from a DHCP scope.
   set property [sc=<savecomment>] [<field1>=<value1>] [<field2>=<value2>]*  ; Set properties for scope.
   show optionvalue                                                          ; Shows DHCP scope options. 
   [<ServerAddress>] set optionvalue  [<field>=<value>,[<value2>]*]          ; Set DHCP scope option. 
     [sc=<savecomment>]
   [<ServerAddress>] delete optionvalue <OptCode>                            ; Deletes a DHCP scope option.
   show reservedoptionvalue <ReservedIP>                                     ; Shows DHCP scope reservation options. 
   set reservedoptionvalue <ReservedIP> [<field>=<value>[,<value2>]*]        ; Sets a DHCP scope reservation option.
     [sc=<savecomment>]
   delete reservedoptionvalue <ReservedIP> <OptCode>                         ; Deletes a DHCP scope reservation option.

scopes [-s] [-d] [<server>]
Lists DHCP scopes. If <server> is specified then it will only list scopes on that server. If the -s parameter is used, the command considers split scopes when calculating free addresses in address pools.  When the -d parameter is used availability of free addresses for individual split scope instances is also displayed.

serverInfo <server>
Lists information about a server. 

servers
Lists all servers available. 

sleep <sec>
Sleeps for the specified number of seconds. 

verify <zonename>
Syntax checks a zone.  Returns a list of syntax errors.  If no errors exist within the zone nothing is returned. 

version
Returns the version number of the program. 

who
Returns a list of users that are logged in. 

zonehistory 
Queries the history log. For detailed description of the command see the History command.

zoneInfo <zonename>
Displays information about a zone. 

zoneModified <zonename>
Returns indication of whether a zone has been modified.  Returns true if zone is modified and needs to be saved.

zoneOptions <zonename>
Returns options for a zone.

zones [-n] [<server>]
Lists all available zones. If the -n argument is specified, zones are sorted alphabetically. If omitted, forward zones are listed first, then reverse zones, and finally slave zones.  The argument <server> is optional. If provided, the command only lists zones on the specified server.


-----------------------------
Example script
-----------------------------
The script below is intended to help you get started using the Men & Mice CLI.  You can use it as a starting point when writing your own scripts.

###############################################
# Demo script for Men & Mice command line interface
###############################################
# start by logging in to Men & Mice Central
login server.acme.com. user password

# print out all zones available
zones

# import a zone file 'zonefile.txt' as the zone 'test.zone.com.'
# on master server 'server.acme.com.'
import test.zone.com. server.acme.com. zonefile.txt

# print the zone
print test.zone.com.

# view the zone change history
zonehistory zone=test.zone.com user=administrator from=2005.2.25


# add one record to it
# NOTE: we can use '-' to refer to the last used zone and -1 means at
# the end of the zone
add - -1 test.record 1d A 10.2.3.4 ; this is comment for the new record

# Disable the third record
disable - 3

# then save it with comments
save - imported this new zone from a file and added one record

# print out all history for the zone, which should of course
# only be the last save comment
history -

# Then quit and we should be back at the OS command prompt
# NOTE: we could skip this command and return to the 
# command prompt of the Men & Mice CLI 
quit