home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / login.ksc < prev    next >
Text File  |  2020-01-01  |  3KB  |  72 lines

  1. ; LOGIN.KSC
  2. ; V4.3 - January 2000
  3. ; This is a general-purpose login script for use with Kermit 95.  It should
  4. ; work with any computer or service that gives a "login:" or "Username:" or
  5. ; "User ID:" prompt, and then a password prompt, and then, if you have logged
  6. ; in successfully, eventually a system prompt such as $ or % or ) on the left
  7. ; margin.  Typical examples include UNIX, VMS, and AOS/VS.  Usage:
  8. ;
  9. ;   SET LOGIN USERID <your-user-id>    (required)
  10. ;   SET LOGIN PASSWORD <your-password> (optional)
  11. ;   SET LOGIN PROMPT <system-prompt>   (optional)
  12. ;
  13. ; or:
  14. ;
  15. ;   autologin <your-user-id> [ <your-password> [ <optional-system-prompt> ] ]
  16. ;
  17. ; If the prompt is specified as NONE, the script CONNECTs immediately
  18. ; after sending the password, without waiting for a system prompt.
  19. ; If no prompt is specified, the script tries a selection of commonly
  20. ; used prompts.
  21. ;
  22. ; If no password is specified AND the prompt is NONE, the script exits
  23. ; immediately after supplying the user ID, so you can type the password
  24. ; yourself.
  25. ;
  26. ; V2:   Block structure, allowance for password-only prompt.
  27. ; V3:   ???
  28. ; V4:   Rename to AUTOLOGIN to avoid clash with new LOGIN command.
  29. ; V4.1: output of password to be compatible with K95 dialer
  30. ; V4.2: check for password afer issuance of user name
  31. ; V4.3: support telnet daemons that issue login prompt with username filled
  32. ;       by telnet environment option
  33. ; V4.4: small typo \m(password) instead of \m(passwd)
  34.  
  35.  
  36. if not defined AUTOLOGIN {
  37.     define AUTOLOGIN {
  38.     local passwd \%i
  39.     if not def \%1 assign \%1 \v(user)
  40.     if not def \%1 end 1 \%0: ERROR - A user ID is required
  41.     asg passwd \%2
  42.     if not def \%3 assign \%3 \v(prompt)
  43.     if not def \%3 assign \%3 NONE
  44.     for \%i 1 5 1 {    
  45.         minput 5 login: Username: {User ID:} {User Name:} {ssword:}
  46.         if success break
  47.         output \13
  48.     }
  49.     if ( > \%i 5 ) end 1 {No response from host}
  50.     if ( < \v(minput) 5 ) {        ; Have username prompt
  51.             input 0 {ssword:}
  52.             if failure {
  53.               lineout \fcont(\%1)        ; Send username
  54.               if not def passwd if eq "" "\v(password)" end 0
  55.           minput 5 {ssword:} {Name?}    ; Wait for password prompt
  56.           if fail end 1 {No password prompt}
  57.             }
  58.     }
  59.     msleep 100              ; Pause for safety
  60.         if def passwd lineout \m(passwd)  ; Send password
  61.         else lineout \v(password)
  62.     if eq "\%3" "NONE" end 0      ; Wait for prompt
  63.     if def \%3 input 20 \%3
  64.     else minput 20 {\13\10$ } {\13\10%\32} {\10\13$\32}  {\13\10)\32}
  65.     if fail end 1 {No system prompt}
  66.     end 0
  67.     }
  68. }
  69. autologin \%1 \%2 \%3
  70. end \v(status)
  71.