Sun N1 Service Provisioning System 5.1 Command-Line Interface Reference Manual

CLI Input and Output

The following sections describe how to use files as input to the CLI and how to use files to store output from the CLI commands.

Redirecting Output to a File

To redirect command output to a file, you can either use the -of argument or use a shell redirect. The argument to the -of argument is a full path to a file.

For example, this command writes the output to a file called hostFile. Note that the -of argument must immediately follow the command specified by -cmd.


cr_cli -cmd hdb.h.add -of hostFile -u user-name
-p password -name myhost -tID NM:system#crhost

After the command is run, hostFile contains output in detail format, which is the default output format for the hdb.h.add command.

Another example of redirecting output to a file involves using a stored session ID to authenticate commands. First, save the RPC-serialized representation of the session ID to a file called session. You can redirect this output to a file using either method.

Once you have stored your session ID in a file, you can use the file as input to another command. See Reading Input From a File.

Reading Input From a File

To pass data from a file to a command, identify the file by adding the prefix file: to the file name.

For example, if you have stored a session ID in a file and want to use the file to authenticate the hdb.h.la command, use the file as input to the command.


cr_cli -cmd hdb.h.la -s file:session

If you did not create the session with the -o serialized argument, you can pass a serialized version of the file to another command by using the ser: prefix.


cr_cli -cmd hdb.h.la -s ser:session

Reading CLI Arguments From a File

To read a CLI argument from an input file, identify the input file by prefixing exp: to the file name. First, create a file that contains the information you want to pass to the CLI. Note that each argument must be listed on a separate line and must appear in the order required by the command.

Then, have the command get the arguments from the file.

For example, these files, file1.txt and file2.txt, can be used in conjunction with exp: to specify command arguments.

file1.txt contains the following:


hdb.h.la
-u
user-name
exp:file2.txt

file2.txt contains the following:


-p
password

To execute the command that is described by these files, type the following:


cr_cli -cmd exp:file1.txt