Cisco Cisco Prime IP Express 8.3 Riferimenti tecnici

Pagina di 289
scope demo1 addReservation 24.10.2.1 1,6,0a:23:45:67:89:01
scope demo1 addReservation 24.10.2.2 1,6,0c:23:45:67:89:02
scope demo1 addReservation 24.10.2.3 1,6,0c:23:45:67:89:03
scope demo1 addReservation 24.10.2.4 1,6,0a:23:45:67:89:04
Note: End the last command line with a newline character, or the command will not be executed.
 
You can then run a single nrcmd session to execute all of these commands.
% nrcmd -b < scope.txt
 
The advantage to using batch files is that you can execute multiple configuration commands while only incurring the connection
cost once. However, if a command fails (such as the initial scope creation in the previous example), the batch file continues
even though subsequent commands are now useless.
You can use the assert function of the session command to perform simple logic checks. This command allows a nrcmd batch
script to assert that a given condition is true. If the condition is true, the command has no effect; if false, the batch file is
terminated at that point. For example, before executing the set of scope commands in the scope.txt file in the previous example,
you might want to ensure that the cluster is locked.
# Quit if cluster cannot be locked
session assert locked
Command Syntax
When you execute nrcmd commands that contain equal-signs, you must put them within quotation marks. For example, to use a
single command to create a client-class name, enter:
nrcmd -C cluster -N name -P password "client MAC create client-class-name= name "
Adding Program Control
A more sophisticated method for automatically configuring and controlling Network Registrar is to have a program or script start
nrcmd session and communicate with the session through standard input and output.
To control nrcmd from another program, you need to start nrcmd from the controlling program and redirect standard input and
output from nrcmd to file handles in the controlling program. The controlling program can then write commands to the input file
handle and read results from the output file handle.
When running in batch mode, nrcmd reads a line of input at a time and prints a new line after the prompt. This provides an
easily parsed sequence of lines in response to any command where:
The syntax is status-line result-lines prompt-line
The status-line has the format [0-9]{3} .*.
There may be zero or more result-lines of any format.
The prompt-line is nrcmd> .
The exact details of starting up nrcmd as a child process, and writing to and reading from its standard input and output, are
specific to the programming language you use to implement the controlling program.