HP Integrity rx2800 HP Integrity iLO 3 Operations Guide - Page 44

Command-line interface scripting, Expect script example

Page 44 highlights

The following is a quick reference list that provides MP Command mode activities: • To access the Command menu, enter CM at the MP Main Menu. • To see all the available commands, enter HE at the CM:hpiLO-> prompt, and then enter LI. • To modify the inactivity timeout, enter the IT command. The inactivity timer aborts a command if you do not complete it within a certain time period and redirects you back to the command prompt. • To abort most commands, enter Q at the point when the iLO 3 MP is asking for input. • To return to the MP Main Menu from any of these commands, press Ctrl-B. Command-line interface scripting A command-line interface is provided for all commands to assist you in scripting. This section provides syntax examples used in the iLO 3 MP command-line or scripted interface. Typically, tools like Expect (see "Expect script example" (page 44)) and (http://expect.nist.gov/) are used to string together several commands to accomplish a task. These scripting tools enable you to write a script for one iLO 3, and use it to apply the same commands to additional iLO 3s. Scripting tools have capabilities that enable you to do the following: • Write scripts that make decisions based on the output of commands • Use variables in the script to customize it for each target automatically • Compensate for delays in output Scripting tools and the command-line interfaces enable you to carry out commands to multiple iLO 3s such as setting the IP address on 10 iLO 3s pulled from a list of 10 IP addresses read from a file local to your script. To automatically administer any part of the system during any stage of its operation, you can use the scripting tool to log in to iLO 3, access the console, and send and receive commands in UEFI or the operating system. NOTE: This guide is not meant as a substitute for instruction on various scripting tools that are available for automating command-line interfaces. The iLO 3 MP TUI (when used with command-line arguments) was created with these types of scripting tools in mind to facilitate powerful automation capabilities. Expect script example The following provides a simple Expect script example with no timeouts and no error checking using Telnet instead of SSH. #!/usr/local/bin/expect -f # # (Portions of) this Expect script (were) was generated by autoexpect on # Tue Nov 21 08:45:11 2006 # Expect and autoexpect were both written by Don Libes, NIST. # # Note that autoexpect does not guarantee a working script. It # necessarily has to guess about certain things. Two reasons a script # might fail are: # # 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, # etc.) and devices discard or ignore keystrokes that arrive "too # quickly" after prompts. If you find your new script hanging up at # one spot, try adding a short sleep just before the previous send. # Setting "force_conservative" to 1 makes Expect do this # automatically - pausing briefly before sending each character. This # pacifies every program I know of. The -c flag makes the script do # this in the first place. The -C flag allows you to define a # character to toggle this mode off and on. 44 Using iLO 3

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152

The following is a quick reference list that provides MP Command mode activities:
To access the Command menu, enter
CM
at the MP Main Menu.
To see all the available commands, enter
HE
at the
CM:hpiLO->
prompt, and then enter
LI
.
To modify the inactivity timeout, enter the
IT
command. The inactivity timer aborts a command
if you do not complete it within a certain time period and redirects you back to the command
prompt.
To abort most commands, enter
Q
at the point when the iLO 3 MP is asking for input.
To return to the MP Main Menu from any of these commands, press
Ctrl-B
.
Command-line interface scripting
A command-line interface is provided for all commands to assist you in scripting. This section
provides syntax examples used in the iLO 3 MP command-line or scripted interface.
Typically, tools like Expect (see
“Expect script example” (page 44)
) and
(h
t
tp://e
xpec
t
.nis
t
.go
v/
)
are used to string together several commands to accomplish a task. These scripting tools enable
you to write a script for one iLO 3, and use it to apply the same commands to additional iLO 3s.
Scripting tools have capabilities that enable you to do the following:
Write scripts that make decisions based on the output of commands
Use variables in the script to customize it for each target automatically
Compensate for delays in output
Scripting tools and the command-line interfaces enable you to carry out commands to multiple iLO
3s such as setting the IP address on 10 iLO 3s pulled from a list of 10 IP addresses read from a
file local to your script. To automatically administer any part of the system during any stage of its
operation, you can use the scripting tool to log in to iLO 3, access the console, and send and
receive commands in UEFI or the operating system.
NOTE:
This guide is not meant as a substitute for instruction on various scripting tools that are
available for automating command-line interfaces. The iLO 3 MP TUI (when used with command-line
arguments) was created with these types of scripting tools in mind to facilitate powerful automation
capabilities.
Expect script example
The following provides a simple Expect script example with no timeouts and no error checking
using Telnet instead of SSH.
#!/usr/local/bin/expect -f
#
# (Portions of) this Expect script (were) was generated by autoexpect on
#
Tue Nov 21 08:45:11 2006
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script.
It
# necessarily has to guess about certain things.
Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts.
If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 makes Expect do this
# automatically - pausing briefly before sending each character.
This
# pacifies every program I know of.
The -c flag makes the script do
# this in the first place.
The -C flag allows you to define a
# character to toggle this mode off and on.
44
Using iLO 3