home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 6
/
Eagles_Nest_Mac_Collection_Disc_6.TOAST
/
DOS
/
PCAnyw50.exe
/
COMPUSRV.SCR
< prev
next >
Wrap
Text File
|
1994-03-05
|
8KB
|
183 lines
;==========================================================================
description "Sample Script To Log Onto Compuserve"
;
; This is a sample script that shows how to log onto Compuserve.
; Your name and password are stored (encrypted) in a file named
; COMPUSRV.DAT. If the file does not exist, you are prompted for your
; UserID and password when the "User Id:" prompt is received.
; The script displays all initial screens and automatically responds with
; your name and password when appropriate.
; The script ends after the main menu is displayed.
; You regain keyboard control when the main is menu is displayed, if you
; press ESC, or if 10 seconds goes by without a recognizable prompt.
;==========================================================================
;==========================================================================
; VARIABLE DECLARATION
;==========================================================================
string _s1[120] ;string for various uses
string _s2[120] ;string for various uses
string _name[30] ;name stored here
string _password[16] ;password stored here
string _datFile[80] ;name of DAT file stored here
string _key[1] ;for inputting a key
integer _i1 ;integer for various uses
;==========================================================================
; MAIN ROUTINE
;==========================================================================
clear screen ;clear the screen
_datFile = "COMPUSRV.DAT" ;name of encrypted data file
find first _datFile ;check if DAT file exists
if ($result == 0) goto @l5 ;not yet - will create later
open 1 _datFile ;open the file
read line 1 _name 30 0 ;read the login name
;For maximum security, should ask user for the encryption key word
decrypt _name "MICKEY" ;decrypt
trim _name ;remove trailing/leading spaces
read line 1 _password 16 0 ;read the password
decrypt _password "MICKEY" ;decrypt
trim _password ;remove trailing/leading spaces
close 1 ;close the file
@l5:
set cancel on ;enable ESC to cancel the script
on cancel goto @cancel
on timeout goto @timeout ;setup overall timeout
set timeout 20 ;to 20 seconds
set disconnect on ;set disconnection trap
on disconnect goto @disconnect
Send string "^C" ;anounce our presence
@L10: ;main loop starts here:
Gosub @getPrompt ;wait for a prompt line
if ($result < 0) goto @timeout ;if we timed out, end the script
@L40:
index _s1 "User Id:" ;if prompting for "userid", send ID
if ($RESULT == 0) goto @L50
strcmp _name "" ;if don't have a name,
if ($result == 0) then gosub @getData ;input from user
Send string _name ;send the name
Send string "^M" ;and a CR
Goto @L10
@L50: ;if prompting for "password", send it
Set ignorecase off ;Do this for exact match of "Password"
Index _s1 "Password:" ;check if "Password"
If ($result == 0) goto @L55 ;branch if not
Send string _password ;else send it
Send string "^M" ;and a CR
Goto @end
@L55:
Set ignorecase on
Goto @L10
@timeout: ;a timeout occurred, end the script
Type string "^M^J(timeout)^M^J"
Goto @end
@cancel: ;user cancelled, so end the script
set cancel off
@cancel1:
type string "^M^JOperator Cancel^M^J"
type string "Hang up (Y/N) ?: " ;ask if should hang up
_s1 = "" ;clear input variable
input _s1 1 ;input name
upper _s1
strcmp _s1 "Y"
if ($result == 0) goto @cancel2 ;if Yes, branch to @cancel2 to hangup
strcmp _s1 "N"
if ($result != 0) goto @cancel1 ;branch if neither Y or N entered
goto @end ;if No, don't hang up but stay
;in terminal mode.
@cancel2:
type string "^M^JHANGING UP..."
Hang
End
@disconnect: ;disconnection, so end the script
Type string "^M^J(disconnected)^M^J"
Goto @end
@end:
beep ;so you know the script has ended
type string "^M^J[YOU ARE NOW IN TERMINAL MODE]^M^J"
end terminal
;==========================================================================
; "@getPrompt" - wait for a prompt line and store it into _s1.
; All lines received are displayed.
; Returns: >=0, length of string
; < 0, timeout occurred
;==========================================================================
@getPrompt:
on timeout goto @g2
wait receive 10 ;wait for something to be received
_s1 = ""
on timeout goto @g1
set timeout 2 ;wait 2 seconds for a line
receive line _s1 ;(will timeout if a prompt received)
type line _s1 ;full line - display on the screen
goto @getPrompt ;and wait for another line
@g1: ;did not get LF, so must be a prompt
Type string _s1 ;display on the screen
strlen _s1 _i1
goto @g3 ;and return
@g2: ;timeout without getting anything
_i1 = -1 ;means something is wrong
@g3:
on timeout goto @timeout ;restore normal timeout
set timeout 20
return _i1 ;return line length or -1 if timeout
; @getData: input login name and password from the user and write to disk.
@getData:
set cancel off
@gd2:
type string "^M^J^JEnter CompuServe Id: "
_s1 = "" ;clear input variable
input _s1 30 ;input name
_name = _s1
encrypt _s1 "MICKEY" ;encrypt it
type string "^M^J^JEnter Password: "
_s2 = ""
input _s2 16 ;input password
_password = _s2
encrypt _s2 "MICKEY" ;encrypt it
type string "^M^J^JOK (Y/N) ?:" ;ask if ok
@gd0:
input key _key ;input Y or N
upper _key ;upper case the response
strcmp _key "Y"
if ($result == 0) goto @gd1 ;branch if yes to save in file
strcmp _key "N"
if ($result != 0) goto @gd0 ;branch if did not press Y or N
goto @gd2 ;branch if no to get again
@gd1: ;save data in file
create 1 _datfile ;create the file
write string 1 _s1 ;save name
write string 1 "^@" ;follow with a null terminator
write string 1 _s2 ;save password
write string 1 "^@" ;follow with a null terminator
close 1 ;close file
set cancel on
return ;exit