Executes commands in a script file.
script, scr, run
script [ <options> ] <script_file> [
[<var_name> ( <var_value> )]
[<var_name> ( <var_value> )]
-l List commands. With this options, commands read from the script file
(including comments) are listed on Stream Error.
NOTE: If you are getting errors from your script, and don't know which
lines are producing those errors, call this command using this option,
so that the command lines will be listed along with errors. The command line
IMMEDIATELY ABOVE THE ERROR is the offending line.
This option is ignored if the -c (compiled script) option is specified.
-p Parse only. With this option, this script is parsed (and any errors listed).
The script is, however, not executed. This option is useful when first
developing a new script. The -l option also needs to be specified if you want
to see the listing and errors.
-c Compiled script. The script file being executed is in compiled format.
Usually, the extension for compiled script files is ".bscs", which stands for
biterScripting Compiled Script. However, the entity that compiled the script
file may have used another extension, which is normal.
If this option is specified, the -l (list commands) option is ignored, as
no source code is available in compiled scripts.
<script_file> Specifies the script file. This can be the name, or relative path or absolute path
of the file containing the script code. The <script_file> can be a script in source format
(a text file, typically with the file extension .txt) or in compiled format (a binary file,
typically with the file extension .bscs).
Parameters (arguments) to the script are passed as <var_name> and
<var_value> using FVA (Forward Variable Assignment).
<var_name> Name of a variable. If this name is preceeded
by $, the variable is assumed to be declared already
outside the invoked script. If the name is not preceeded
by $, the variable is assumed to be declared inside the
<var_value> Value of the variable <var_name>. This can be a constant,
variable (must have $ sign, that means already declared),
expression, inline command, another function, or
a combination of these.
Stream input to the script command is fed as stream input to the first
command within the script.
Stream output from the executed commands is produced here.
In interactive mode, The lines read within the script are
reported here, if the -l option is specified.
Any errors encountered are also listed here.
Commands in script file are executed.
Stream redirection is allowed. If the redirection is specified using
>>, output from all commands within the script file is appended to
the redirection target. If redirection is specified using >,
output from all commands within the script file is written over
the redirection target.
Of course, to provide flexibility, individual commands within the
script file can have their own redirection, which takes precedence
over the redirection specified on the script command.
This command uses the system variable $path to search for the files
containing scripts. This is a string variable, and its value has
the following syntax
" <directory> [ | <directory> [ | <directory> [ ... ] ] ] "
Directories within this variable are separated by the pipe character (|) .
There should be no extraneous spaces in the value of $path variable.
When a script command is encountered, each directory in this list is
searched from beginning to end for the specified script. The first script
found is executed.
It is recommended that you set the value of $path in the startup script
based on the needs of your project. The $path variable can contain relative
paths, but absolute paths are highly recommended.
IMPORTANT: The $path variable CAN CONTAIN Internet locations such as
"http://www.mycompany.com/scripts", if you execute scripts
directly from the internet.
File patterns are not allowed when calling a script for one specific reason.
If file patterns are used inadvertantly, it may produce undesired retults.
For that reason, the script command forces the user to explicitly specify
the name of the file containing the script.
In batch mode, with the -l option, the lines read within the script are NOT
reported to stream error.
Variables declared inside a script remain local to the script
and are not available outside. To make these variables available
outside, use the -g option in the var command, which will make them
A script can not call itself recursively. Similarly,
two scripts can not call each other mutually.
Will execute commands in file myscript.txt.
Will execute commands in file myscript.txt in
The following example shows the difference between Current
Variable Assignment (assigning values to variables already declared)
and FVA or Forward Variable Assignment (assigning values to
variables NOT declared yet).
var int custNo
script myscript.txt custNo(5) custName("John Doe")
Variable custNo is already declared. Before execution
begins, variable $custNo will be assigned value 5.
$custNo will retain this value after completion of script
execution, unless the script changes its value during its
Variable custName is not declared outside of the script.
So, it will be assumed to be declared within the
script. If so, the value "John Doe" will be assigned to
$custName before execution of the script. Variable
$custName will NOT be available outside of the script.
script -c "C:/Scripts/parse.bscs"
Will execute commands in the specified compiled script file.
script -c "C:/Scripts/parse.abc"
Will execute commands in the specified compiled script file. Even though the file
extension is not ".bscs", this is perfectly normal and the file will be treated
as compiled script file.
The intention is to execute scripts in files whose
names match the pattern *.scr. This will produce an
Will also produce an error. File patterns are not allowed
within the script command to prevent un-intentional execution
of commands in script files.