Technical References
Because nrcmd does a significant amount of processing at connect time, it is more efficient to perform
multiple commands in a single session rather than to initiate a distinct connection and login for each
command. The simplest way to have a single nrcmd session perform multiple commands is to create a
batch file with one command per line and to redirect standard input from that file. A more complicated
approach, but one that provides more control over the command sequence, is to run nrcmd from a
controlling program and have that program send commands and read their status and output.
Using nrcmd Batch Files
The simplest way to automatically perform multiple configuration commands is to create a batch file of
nrcmd commands and have them executed sequentially. For example, to create a scope and add
reservations to it, you can enter these commands and store them in the file scope.txt. Lines beginning
with the pound character (#) are comment lines:
# This set of commands creates a scope and adds four reservations
scope demo1 create 24.10.2.0 255.255.255.0
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