Solstice PPP 3.0.1 Administration Guide

Editing the CHAT (or Connect) Scripts

The CHAT (or connect) scripts define the exchange of information between the endpoints, which occurs during the link establishment phase. By default, the CHAT scripts are located in the directory /etc/opt/SUNWconn/ppp/script. You can change the location of the scripts by editing the location definition in the file link.conf, and moving the files.

You must create one CHAT script for each remote host to which the local host will initiate calls. It must contain a unique login id, which must correspond to a user account on the remote machine. If the remote host is running Solstice PPP, the login id must also appear as the value of the parameter expect_login_id associated with one of the dialup paths in the file ppp.conf on this machine.

CHAT scripts may be non-interactive (all the information to be exchanged is contained in the script) or interactive (the script prompts for user input).

The following example shows a simple CHAT script used to log in to remote hosts running a Solaris operating system. It is based on the template CHAT script delivered with Solstice PPP.


# Chat script for ppp login
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
# Start dialog with the remote host
send    	RETURN
 
# Set expected response, retry 3 times at 10 second intervals
expect  	"ogin:"  10  onerror send BREAK repeat 3
 
# Set login id sent to remote host
send    	"ppp1"
 
# Set response expected from remote host
expect  	"word: " 40
 
# Set the login password sent to the remote host
send	    "okppp1"

Changing the Login Id and Password

The login id and login password are used for the login sequence at the remote host. This sequence and the restrictions it imposes on the login dialog is operating system dependent.

If the remote host is running a Solaris environment, the login id must be all lowercase, and between 1 and 8 characters in length. The login password can contain both uppercase and lowercase characters, and must be equal to, or greater than, 6 characters in length; however, only the first 6 characters are significant.


Note -

To accept the call, there must be a user account with this login id and password on the remote host. If the remote host is running Solstice PPP the login id must also appear as the value of the expect_login_id parameter for one of the dialup paths in the file ppp.conf.


Edit the default CHAT script to replace the login id and the login password with the strings expected by the remote host. For example, the following CHAT script is used to establish a link with a login id mylogin and login password mypasswd.


# Chat script for ppp login
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
# Start dialog with the remote host
send    	RETURN
 
# Set expected response, retry 3 times at 10 second intervals
expect  	"ogin:"  10  onerror send BREAK repeat 3
 
# Set login id (mylogin) sent to remote host
send    	"mylogin"
 
# Set response expected from remote host, wait up to 40 seconds
expect  	"word: " 40
#
# Set the login password (my passwd) of the remote host
send	    "mypasswd"

Changing the Number of Call Initiation Attempts

When the call is first initiated, the local host waits for a response from the remote host to begin the login sequence. The length of time the local host waits and the number of times the local host attempts to initiate the call are defined by the following entry:


expect  	"ogin:"  10  onerror send BREAK repeat 3

The first figure (10) defines the wait period, and the second figure (3) defines the number of call initiation attempts. You can modify both of these parameters.

For example, to retry the call initiation once every 5 seconds for a total of 10 attempts, change the line in the file to:


expect  	"ogin:"  5  onerror send BREAK repeat 10

Changing the Login Dialog

The default CHAT script assumes that a link is to be established between two Solaris systems. If you are connecting to a machine running operating system you may need to change the expected login dialog.

For example, to connect to an OpenVMS system running PPP, modify the connect script as follows:


send    	RETURN
# Change "ogin:" to "name:" for OpenVMS
expect  	"name:"  10  onerror send BREAK repeat 3
 
send    	"ppp"
expect  	"word:" 40
#
# Set the ppp password of the remote host here
#
send	    "xxxxx"

The template CHAT script supports a simple method of logging in to a remote host. You can also modify and expand the CHAT script to create a more complex login dialog. Note that to initiate connections to a remote host running Solstice PPP, you must include a login id that is recognized by the remote host, and provide a way to start the Solstice PPP login service.

For example, the following CHAT script could be used to log in to a remote host running a Solaris environment, invoke mailx(1) to send an email message to indicate that the operation was successful, and start the Solstice PPP login service. Note that, in this case, the user account on the remote host that corresponds to the login id sent by the script must use /usr/bin/csh as the default shell.


# Chat script to invoke mailx on remote
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
# Start dialog with the remote host
send    	RETURN
 
# Set expected response, retry 3 times at 10 second intervals
expect  	"ogin:"  10  onerror send BREAK repeat 3
 
# Set login id (mylogin) sent to remote host
send    	"mylogin"
 
# Set response expected from remote host, wait up to 40 seconds
expect  	"word: " 40
#
# Set the login password (my passwd) of the remote host
send	    "mypasswd"
 
# Set response expected from remote host (C-shell prompt)
expect	  "%"
 
# Set command sent to invoke mailx
send	  "echo Login to remote successful | /usr/bin/mailx alias"
 
# Set response expected from remote host (C-shell prompt)
expect	  "%"
 
# Start PPP login service (pppls) on remote
send	    "/usr/sbin/pppls"

The following CHAT script could be used to log in to a telnet terminal server:


# Chat script to login to telnet server
#
# Set the line regarding the remote site configuration
# Due to UUCP limitations some systems only accept cs7
# setline 	cs7 parodd
 
 
send    RETURN
expect  "sername:" 10 onerror send RETURN repeat 5
 
send    "your_username"
expect  "assword:" 35
 
send    "your_password"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "terminal flowcontrol hardware"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "terminal databits 8"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "terminal parity none"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "terminal escape-character 0"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "terminal telnet-transparent"
expect  "pc>" 10 onerror send RETURN repeat 2
 
send    "telnet your_own_machine"
expect  "ogin:" onerror send RETURN repeat 5
 
send    "your_login_for_PPP"
expect  "assword:" 35
 
send    "your_password _for_PPP"

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.

CHAT Script Syntax

The CHAT script syntax, as described using BNF, is as follows:


<chat_script>   ::= <script_cmd> | <chat_script> <script_cmd>
<script_cmd>    ::= <send_cmd> | <expect_cmd> | <echo_cmd> |
<read_cmd>
<send_cmd>      ::= "send" <quoted_string> | "send RETURN" | "send
BREAK"
<expect_cmd>    ::= "expect" <quoted_string> <number>
<expect_error>
<expect_error>  ::= "" | "onerror" <send_repeat>
<send_repeat>   ::= <send_cmd> <repeat> | <send_cmd> | <repeat>
<repeat>        ::= "repeat" <number> | "repeat"
<echo_cmd>      ::= "echo" <quoted_string>
<read_cmd>      ::= "read" <string>
<quoted_string> ::= "((<string>|<number>)[ ]*)+"
<string>        ::= ([a-zA-Z/_-&.%#@~+*\(){}$;:?><!]+[0-9"']*)+
<number>        ::= ([0-9,@*#$]*.)?[0-9,@*#$]+