home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / mincom15.zip / unixlogin < prev    next >
Text File  |  1993-04-22  |  885b  |  46 lines

  1. # Generic UNIX login script.
  2. # Can be used to automatically login to almost every UNIX box.
  3. #
  4.     # Some variables.
  5.     set a 0
  6.     set b a
  7.     print Trying to Login..
  8.     # Skip initial 'send ""', it seems to matter sometimes..
  9.     goto skip
  10. loop1:
  11.     # Send loginname not more than three times.
  12.     send ""
  13.     inc a
  14. skip:
  15.     if a > 3 goto failed1
  16.     expect {
  17.         "ogin:"
  18.         "assword:"    send ""
  19.         "NO CARRIER"    exit
  20.         timeout 2    goto loop1
  21.     }
  22. loop2:
  23.     send "$(LOGIN)"
  24.  
  25.     # Send password not more than three times.
  26.     inc b
  27.     if b > 3 goto failed1
  28.     expect {
  29.         "assword:"
  30.         "ogin:"        goto loop2
  31.         timeout 2    goto loop2
  32.     }
  33.     send "$(PASS)"
  34.     # If we don't get "incorrect" within 3 seconds, it's probably OK.
  35.     # If they ask for a terminal, we are logged in. Tell them we're
  36.     # using vt100.
  37.     expect {
  38.         "TERM="        send "vt100"
  39.         "incorrect"    goto loop1
  40.         timeout 3     break
  41.     }
  42.     exit
  43. failed1:
  44.     print \nLogin Failed (wrong password?)
  45.     exit
  46.