To run this script file after uploading, the CLI command would be:
gw-world:/> script -execute -name=my_script.sgs 126.12.11.01 "If1 address"
When the script file runs, the variable replacement would mean that the file becomes:
add IP4Address If1_ip Address=126.12.11.01 Comments="If1 address"
Escaping Characters
Sometimes, there is a requirement to escape certain characters in a command so they are treated
as ordinary characters when the command is executed. This is particularly true for the dollar-sign
"
$
" character. Consider the string: "
te$t
". In order to have the dollar-sign treated as a normal
character, it can be escaped in the normal way by using a backslash "
\
" character. The string
would become "
te\$t
" and the dollar-sign is no longer treated as special.
Script Validation and Command Ordering
CLI scripts are not, by default, validated. This means that the written ordering of the script does
not matter. There can be a reference to a configuration object at the beginning of a script which
is only created at the end of the script.
Although this approach might seem illogical, it is done to improve the readability of scripts. If
something always has to be created before it is referred to then this can result in confused and
disjointed script files and in large script files it is often preferable to group together related CLI
commands.
Error Handling
If an executing CLI script file encounters an error condition, the default behavior is for the script
to terminate. This behavior can be overridden by using the
-force
option.
For example, to run a script file called
my_script2.sgs
in this way so that errors do not terminate
execution, the CLI command would be:
gw-world:/> script -execute -name=my_script2.sgs -force
If
-force
is used, the script will continue to execute even if errors are returned by a command in
the script file.
Script Output
Any output from script execution will appear at the CLI console. Normally this output only
consists of any error messages that occur during execution. To see the confirmation of each
command completing, the
-verbose
option should be used:
gw-world:/> script -execute -name=my_script2.sgs -verbose
Saving Scripts
When a script file is uploaded to the NetDefend Firewall, it is initially kept only in temporary RAM
memory. If NetDefendOS restarts then any uploaded scripts will be lost from this volatile
memory and must be uploaded again to run. To store a script between restarts, it must explicitly
be moved to non-volatile NetDefendOS
disk
memory by using the
script -store
command.
Chapter 2: Management and Maintenance
60
Summary of Contents for NetDefendOS
Page 30: ...Figure 1 3 Packet Flow Schematic Part III Chapter 1 NetDefendOS Overview 30 ...
Page 32: ...Chapter 1 NetDefendOS Overview 32 ...
Page 144: ...Chapter 2 Management and Maintenance 144 ...
Page 284: ...Chapter 3 Fundamentals 284 ...
Page 392: ...Chapter 4 Routing 392 ...
Page 419: ... Host 2001 DB8 1 MAC 00 90 12 13 14 15 5 Click OK Chapter 5 DHCP Services 419 ...
Page 420: ...Chapter 5 DHCP Services 420 ...
Page 573: ...Chapter 6 Security Mechanisms 573 ...
Page 607: ...Chapter 7 Address Translation 607 ...
Page 666: ...Chapter 8 User Authentication 666 ...
Page 775: ...Chapter 9 VPN 775 ...
Page 819: ...Chapter 10 Traffic Management 819 ...
Page 842: ...Chapter 11 High Availability 842 ...
Page 866: ...Default Enabled Chapter 13 Advanced Settings 866 ...
Page 879: ...Chapter 13 Advanced Settings 879 ...