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.
To redirect command output to a file, use the -of argument. 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.
cr_cli -cmd hdb.h.add -of hostFile -u user-name -p password -name myhost -tID NM:roxhost |
After the command is run, hostFile contains output in detail format, which is the default output format for the hdb.h.add command.
Note that the -of argument must immediately follow the command specified by -cmd.
To read in data from a file, identify the file by prefixing file: to the file name.
For example, you might want to store the session ID of the session you have just started and use it later to authenticate commands. First, save the RPC-serialized representation of the session ID to a file called session.
cr_cli -cmd udb.login -u user-name -p password -o serialized > session |
Then, use the session ID in the session as input to another command.
cr_cli -cmd hdb.h.la -s file:session |
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 |