Operations and Maintenance Guide, Second Edition - HP Integrity rx2600 Server and HP zx6000 Workstation

HP Integrity rx2600 server and HP workstation zx6000 Operation and Maintenance Guide 29
System Configuration
To run a shell script:
1. Enter the name of the command at the EFI shell prompt. For example:
fs0:\> mytest.nsh
2. Press Enter.
Positional Arguments
Up to nine positional arguments are supported for batch scripts. Positional argument substitution
is performed before the execution of each line in the script file. Positional arguments are denoted
by
%n, where n is a digit between 0 and 9. By convention, %0 is the name of the script file
currently being run.
In batch scripts, argument substitution is performed first, then variable substitution. For example,
for a variable containing
%2, the variable is replaced with the literal string %2, not the second
argument on the command line. If no real argument is found to substitute for a positional
argument, the positional argument is ignored.
For example, this script replaces the two literal arguments
arg1 and arg2 with the positional
arguments
%1 and %2:
#
# Example: EFI Shell Script
#
#///////////////////////////////////////
echo -off
set arg1 %1
set arg2 %2
echo "I found a %arg1%"
echo "I also found a %arg2%"
To run the command, enter the command name followed by the arguments at the shell
prompt:
fs0:\efi\tools> example cat dog
example> echo -off
I found a cat
I also found a dog
Nesting
Script file execution can be nested; that is, script files may be run from within other script files.
Recursion is allowed.
Output Redirection
Output redirection is fully supported. Output redirection on a command in a script file causes the
output for that command to be redirected. Output redirection on the invocation of a batch script
causes the output for all commands in the batch script to be redirected to the file, with the output
of each command appended to the end of the file.
By default, both the input and output for all commands run from a batch script are echoed to the
console. Display of commands read from a batch file can be suppressed using the
echo -off
command (see
echo). If output for a command is redirected to a file, then that output is not
displayed on the console.