Let's look at the individual statements and syntax of a Batch Console script. All statements are confined to a single line, except for the "if" statement.
This command
|
Does this
|
connect [to] service_name [port] number
|
Connects to the given service as a console. If the service name is an IP address or contains non alphanumeric characters, it must be enclosed in double quotation marks.
|
enable [[data] source] name
|
Enables the specified data source. If the data source doesn't exist, an error occurs.
If the data source is not disabled, no command is executed and a warning results. This will not cause the script to terminate prematurely. To eliminate the warning, use an "if" statement; this test whether the data source is disabled before trying to enable it.
|
disable [[data] source] name
|
Disables the specified data source. If the data source does not exist, an error occurs.
If the data source is disabled, no command is executed and a warning results. This will not cause the script to terminate prematurely. To eliminate the warning, use an "if" statement; this test whether the data source is disabled before trying to enable it.
|
process [[data] source] name [[with] option[s] “option_list”] [reclone ds_list]
|
Initiates a process command. The options are specified the same as on the dbutility command line, using either slashes or a hyphen (depending on the operating system) followed by a letter and an argument, if applicable.
When specifying options, you must include the keyword option to indicate that a list of options follows the command. Make sure that you separate each option with a space and enclose the entire set of options with double quotation marks. The program will validate the options before passing them to the service.
You can force all of the specified data sets to be recloned by adding the keyword reclone followed by a list of data sets to the process command. This sets the ds_mode to 0 for all the specified data sets in a single command. If you use the name "all", all data sets will be recloned; you don't need to name them individually.
|
clone [[data] source] name [[with] option[s] “option_list” ] ds_list
|
Initiates a clone command. The options are specified like you would in dbutility, using slashes or dashes (depending on the operating system) followed by a letter and an argument when applicable.
|
[re]define [[data] source] name [[with] option[s] “option_list”]]
|
Initiates a redefine or define command, depending on whether the data source exists. This statement causes the service to launch DBClientCfgServer for the data source (unless it is already running) and then execute a define/redefine command.
|
reorg[anize] [[data] source] name [[with] option[s] “option_list”]]
|
Initiates a reorganize command. This statement causes the service to launch DBClientCfgServer for the data source (unless it is already running) and then execute a reorg command.
|
generate [[data] source] name [[with] option[s] “option_list”]]
|
Initiates a generate command. The statement causes the service to launch DBClientCfgServer for the data source (unless it is already running) and then execute a generate command.
|
stop [run [for [[data] source]]] name [{after [afn] number | at [time] hh:mm}]
|
This is equivalent to the DBConsole Stop command. If nothing is specified the run will stop at the next quiet point, otherwise the run will stop at the first quiet point after the specified time (Client machine time) or at the first quiet point after the given AFN.
|
abort [run [for [[data] source]]] name
|
This is equivalent to the DBConsole Abort command. The Client run is terminated immediately by closing the TCP/IP connection to the server. This will cause the last transaction group to be rolled back by the Client.
|
status [[[data] source] name]
|
This command writes the status of a data source to the Batch Console (bconsole) log file. If the data source name is omitted, or the name “_all” is used, the status of all data sources is written to the log file.
|
display “string”
|
This command writes the given string to the log file. It is mainly intended to help debugging.
|
if expression then
...
[else
...
]
end [if]
|
The block of commands following the "if" line, which must end with the keyword "then", are executed if the expression evaluates to true. This block ends with either an "else" or “end [if]” keyword (in the absence of an else clause). The else clause starts a new block of commands that will be executed if the expression in the “if” statement evaluates to false. In all cases “end [if]” ends the block that is started by a "then" or "else".
|
launch [[[data] source]] name cmd_file params
|
This command makes the service launch an arbitrary command file. It is only useful in debugging BCNOTIFY scripts, as this is the easiest way to launch them.
For name, list the data source name. If the run is not associated with a specific data source, use "_none" (quotation marks not required). The cmd_file is the filename of the script in the scripts subdirectory of the service's working directory that you want the service to launch. cmd_file and params must be enclosed in double quotation marks if they contain non alphanumeric characters, such as a period (.).
|
disconnect
|
This command tells the program to disconnect from the given service it is connected to. This command will not normally be needed, as the program will automatically issue it when it reaches the end of the script file.
|
wait (integer value)
|
This command injects a delay, (measured in seconds) in execution of the script file. It is mainly intended for debugging purposes.
|
exit (integer value)
|
This command stops the program and returns the specified exit code. The command is only needed to return a non-zero exit code or to stop the flow of execution within an “if” statement.
|