select the “Power Device Needs a Login” option to display a Login Dialog field for entering your login script.
Login Dialog (chat style)
This editable field is where you should enter the login script for your power control device, if it’s required by your power control device. Refer to the user guide of your power control device for correct information. A script consists of one or more
login: myid
password: mypass
This script indicates that the switch should expect the string “login:” and, once it’s received the “login:” prompt, the switch will send the string “myid” and then expect the “password:” prompt. When it receives the prompt for the password, it will send the password “mypass.” A carriage return — normally sent following the reply string — is not expected in the expect string unless it is specifically requested by using the \r character sequence.
If the script must start by sending something instead of waiting for an expect string, use the null sequence ‘’ (two single quotes with no space in between) as the expect string:
‘’ restart login: myid password: mypass
In other words, send “restart” and then expect “login:” and then send “myid” and then expect “password” and then send “mypass.” The expect sequence should contain only what’s needed to identify the string. For example, to help correct for characters which may be corrupted during the initial sequence, look for the string “ogin:” rather than “login:” to see if the initial letter (“l”) was received in error. You may never find the string even though it was sent by the power device, so, for this reason, the script should look for “ogin:” rather than “login:” and “ssword:” rather than “password:” — like this:
ogin: myid
ssword: mypass
Again, in other words, expect “ogin:” and then send “myid” and then expect “ssword:” and then send “mypass.”
Comments
A comment is a line that starts with the pound sign (“#”) in column 1. Such comment lines are just ignored. If a “#” character is to be expected as the first character of the expect sequence, you should set the expect string in single quote marks (‘’). If you want to wait for a prompt that starts with a pound sign, you would need to write something like this:
#Now wait for the prompt and send “logout” ‘#’ logout
Escape Sequences
The expect and reply strings may contain escape sequences. All of the sequences are legal in the reply string; many are legal in the expect. Those not valid in the expect sequence are so indicated.
A pair of single quotes or apostrophes (‘’ or ’’) — Expects or sends a null string. If you send a null string, then it will still send the return character.
\b — Represents a backspace character.
\c — Suppresses the new line at the end of the reply string. This is the only way to send a string without a trailing return character. It must be at the end of the send string. For example, the sequence “hello\c” will simply send the letters “h,” “e,” “l,” “l,” “o” (not valid in expect).
\d — Delays for one second (not valid in expect). \n — Sends a new line or linefeed character.
\N — Sends a null character. The same sequence may be represented by “\0” (not valid in expect).
MANAGEMENT OVER A BROWSER | 45 |
|