home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / DIP / _DIP.TAR / usr / doc / dip / samples / sample-paul.dip < prev    next >
Encoding:
Text File  |  1995-01-13  |  2.8 KB  |  125 lines

  1. #!/usr/sbin/dip
  2. #
  3. # Connection script for SLIP from east.alma-ata.su to itpm.alma-ata.su
  4. #
  5. # This script calls to two different phones on the same machine
  6. # On first and second pass we calls PHONE1, on third - PHONE2.
  7. # If we connected at some phone, next try to connect starts with
  8. # this phone number.
  9. #
  10. # By Paul Cadach (Alma-Ata)
  11. #
  12. # note, that some of the features used in this script, are
  13. # deemed dangerous security-wise by me (Uri) and are thus
  14. # disabled in the DIP code. In order to enable them, look
  15. # through the source, mainly of "command.c"...
  16.  
  17.   chatkey    NO\sCARRIER    4
  18.   chatkey    NO\sDIALTONE    5
  19.   chatkey    BUSY        6
  20.  
  21. # Fetch the IP address of our target host.
  22. main:
  23.   print Initializing networking parameters...
  24.   get $local east
  25.   get $remote itpm
  26.   network
  27.  
  28.   # Set the desired serial port and speed
  29.   get $phone 0
  30. redial:
  31.   print Initializing serial port and modem...
  32.   port cua0
  33.   if $errlvl != 0 goto badtty
  34. #  speed 9600
  35.  
  36.   # Reset the modem and terminal line.
  37. #  reset
  38.  
  39.   # Prepare for dialing.
  40.   init AT&FQ0V1X4B0E0\K5\Q3\J\V3%C1%E1S10=14S7=60
  41.   print Dialing to $remote [ $rmtip ]...
  42.   inc $phone
  43.   if $phone != 4 goto phone_ok
  44.   get $phone 1
  45. phone_ok:
  46.   if $phone == 3 goto phone2
  47. phone1:
  48.   dial PHONE1 90
  49.   goto check_dial
  50. phone2:
  51.   dial PHONE2 60
  52. check_dial:
  53.   if $errlvl == 1 goto login
  54.   if $errlvl == 3 goto dialtimeout
  55.   if $errlvl == 4 goto nocarrier
  56.   if $errlvl == 5 goto nodialtone
  57.   if $errlvl == 6 goto busy
  58.   goto error
  59.  
  60. # We are connected. Login to the system.
  61. login:
  62.   print Login to the system...
  63.   sleep 1
  64. #  send \r\n\r\n
  65.   wait ogin: 30
  66.   if $errlvl == 3 goto chattimeout
  67.   if $errlvl != 0 goto error
  68.   sleep 1
  69.   send YOUR-LOGIN\n
  70.   wait ord: 10
  71.   if $errlvl == 3 goto chattimeout
  72.   if $errlvl != 0 goto error
  73.   sleep 1
  74.   send YOUR-PASSWORD\n
  75.   wait SLIP 30
  76.   if $errlvl == 3 goto chattimeout
  77.   if $errlvl != 0 goto error
  78.  
  79. done:
  80.   config pre  routing del east.alma-ata.su
  81.   config pre  interface dummy down
  82.   config up   routing add irbis.alma-ata.su gw itpm.alma-ata.su
  83.   config down routing del irbis.alma-ata.su
  84.   config post interface dummy east.alma-ata.su up
  85.   config post routing add east.alma-ata.su
  86.   print CONNECTED to $remote [ $rmtip ]
  87.   set $mtu 576
  88.   mode SLIP
  89.   sleep 10
  90.   dec $phone
  91.   goto redial
  92.  
  93. nocarrier:
  94.   print Dialing failed (NO CARRIER), repeating...
  95.   goto redial
  96.  
  97. nodialtone:
  98.   print Dialing failed (NO DIALTONE), repeating after delay (20 sec)...
  99.   sleep 20
  100.   goto redial
  101.  
  102. busy:
  103.   print Dialing failed (BUSY), repeating after delay (20 sec)...
  104.   sleep 20
  105.   goto redial
  106.  
  107. chattimeout:
  108.   print Timeout in chat script, repeating...
  109.   goto redial
  110.  
  111. dialtimeout:
  112.   print SLIP to $remote [ $rmtip ] failed (TIMEOUT while dialing)
  113.   goto exit
  114.  
  115. badtty:
  116.   print Cannot open TTY line
  117.   goto exit
  118.  
  119. error:
  120.   print SLIP to $remote [ $rmtip ] failed
  121. #  reset
  122.  
  123. exit:
  124.  
  125.