Solstice PPP 3.0.1 Administration Guide

Interactive CHAT Scripts

Interactive CHAT scripts use echo and read keywords to display prompts and to acquire user input. The user input is stored as variables, which are identified by the $ prefix. For example, an interactive version of the previous script could be:


# Interactive Chat Script Example 1
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
send	RETURN
expect  	"ogin:"  10  onerror send BREAK repeat 3
 
# Display prompt for login id
echo	"Enter your PPP login id: "
 
# Read the login id from standard input and store in $login
read	$login
 
# Send the login id to the remote host
send	"$login"
 
# Set expected response, wait up to 40 seconds
expect  	"word: " 40
 
# Display prompt for password
echo	"Enter your PPP password: "
 
# Read the password from standard input and store in $password
read	$password
 
# Send the password to the remote host
send	"$password"

A more complex example shows a CHAT script used to manage the interaction between the user and a dynamic challenge-response authentication system:


# Interactive Chat Script Example 2
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
send	RETURN
expect  	"ID:"  10  onerror send BREAK repeat 3
 
# Display prompt for user number id
echo	"Enter your user ID number: "
 
# Read the user number id from standard input and store in $id
read	$id
 
# Send the user number id to the remote host
send	"$id"
 
# Set expected response, wait up to 10 seconds
# Receive the 6 character challenge code
expect	"Challenge: ${challenge,6}" 10
 
# Display prompt for the challenge response
echo	"Enter the response for Challenge ${challenge}: "
 
# Read the user number id from standard input
# and store in $response
read	$response
 
# Send the challenge response to the remote host
send	"$response"
 
# Set expected response, wait up to 20 seconds
expect	"${host}:" 20
 
# Display status and name of remote host on successful connection
echo	"Connected to ${host}\n"
 
# Start dialog with remote PPP
send	"ppp"

In this example, the script reads a user id and sends it to the server. It waits for 10 seconds for a response from the server that starts with the string Challenge: and then reads the next six characters which represent the challenge value.

The script then displays the challenge value, waits for the user to enter the corresponding response, and sends this to the server. If the response is accepted, the connection is completed.

The {} brackets are used to delimit a variable when it appears with other characters as part of a character string.