Prima IP User Manual Rev 1.5 2007
- -
59
the password "mypass". A carriage return is normally sent following the reply strings. It is not expected in
the expect strings unless it is specifically requested by using the \r character sequence.
If the script must start by sending something instead of waiting for a string, use the null sequence '' (two
quotes with no space in between) as expect string:
'' restart
login: myid
password: mypass
In other words send "restart", expect "login:", send "myid", expect "password", send "mypass".
The expected sequence should contain only what is needed to identify the string. For example, to help correct
for characters that may be corrupted during the initial sequence, look for the string "ogin:" rather than
"login:". It is possible that the leading "l" character may be received in error and you may never find the
string even though it was sent by the power device. For this reason, the script should look for "ogin:" rather
than "login:" and "ssword:" rather than "password:" like this:
ogin: myid
ssword: mypass
In other words, expect "ogin:", send "myid", expect "ssword:", send "mypass".
A comment is a line which starts with the # (hash) character 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 quote the
expect string. If you want to wait for a prompt that starts with a # (hash) character, you would have 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 string. Those which are not valid in the expect sequence are so indicated.
''
Expects or sends a null string. If you send a null string then it will still send the return character. This
sequence may either be a pair of apostrophe or quote characters.
\b
represents a backspace character.
\c
Suppresses the newline at the end of the reply string. This is the only method 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 characters h, e, l, l, o. (not valid in expect.)
\d
Delay for one second. (not valid in expect.)
\n
Send a newline or linefeed character.
\N
Send a null character. The same sequence may be represented by \0. (not valid in expect.)
\p
Pause for a fraction of a second. The delay is 1/10th of a second. (not valid in expect.)
\r
Send or expect a carriage return.
\s
Represents a space character in the string. This may be used when it is not desirable to quote the strings
which contains spaces. The sequence 'HI TIM' and HI\sTIM are the same.
\t
Send or expect a tab character.
\\
Send or expect a backslash character.
Refer to the Linux chat program man page (man 8 chat) to get more details.