#
# sample1.dip	Dialup IP connection support program.
#		This  file  (should  show)  shows how  to use the  DIP
#		scripting commands to establish a link to a host.
#		This host  runs the 386bsd operating system,  and thus
#		can only be used for the "static" addresses.
#
#
# Version:	@(#)samples/sample1.dip	1.01	23.April.1995
#
#
# Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
#
#
#		This program is free software; you can redistribute it
#		and/or  modify it under  the terms of  the GNU General
#		Public  License as  published  by  the  Free  Software
#		Foundation;  either  version 2 of the License, or  (at
#		your option) any later version.
#
#		This program is  distributed in the  hope that it will
#		be useful, but WITHOUT ANY WARRANTY;  without even the
#		implied warranty of MERCHANTABILITY  or  FITNESS FOR A
#		PARTICULAR  PURPOSE.    See  the  GNU  General  Public
#		License for more details.
#
#		You  should have received  a copy  of the  GNU General
#		Public License along with this program;  if not, write
#		to the
#			Free Software Foundation, Inc.
#			675 Mass Ave
#			Cambridge, MA 02139, USA
#

main:
  # First of all, set up our name for this connection.
  # I am called "uwalt.hacktic.nl"  (== 193.78.33.238)
  #
  get $local uwalt.hacktic.nl

  # Next, set up the other side's name and address.
  # My dialin machine is called
  #   'xs4all.hacktic.nl' (== 193.78.33.42)
  #
  get $remote xs4all.hacktic.nl

  # Set the desired serial port and speed.
  #
  port tty01
  speed 38400

  # Reset the modem and terminal line.
  # This seems to cause trouble for some people!
  #
  reset

  # Prepare for dialing.
  #
  send ATQ0V1E0X4\r
  wait 2 OK
  if $errlvl != 1 goto modem_trouble

  dial 555-1234567
  wait 60 CONNECT
  if $errlvl != 1 goto modem_trouble

login:
  # We are connected.  Login to the system.
  #
  sleep 2
  wait 20 ogin:
  if $errlvl != 1 goto login_error

  send MYACCOUNT\n
  wait 20 assword:
  if $errlvl != 1 goto password_error

  send MYPASSWORD\n

loggedin:
  # We are now logged in.
  # Now wait for a prompt or whatever you want.
  #
  wait 15 SOMETEXT
  if $errlvl != 1 goto prompt_error

  # Set up the SLIP operating parameters.
  #
  get $mtu 296
  default

  # Say hello and fire up!
done:
  print CONNECTED $locip ---> $rmtip
  mode CSLIP
  goto exit

prompt_error:
  print TIME-OUT waiting for SLIPlogin to fire up...
  goto error

login_trouble:
  print Trouble waiting for the Login: prompt...
  goto error

password_error:
  print Trouble waiting for the Password: prompt...
  goto error

modem_trouble:
  print Trouble ocurred with the modem...

error:
  print CONNECT FAILED to $remote

exit:
