home *** CD-ROM | disk | FTP | other *** search
- ASSIGN S0 "****" ; This is the logon password we'll use
- ASSIGN S3 "xxxx" ; This is the DOS password we'll use
- ; trace on ; Debugging
- ;
- ; ----- COM-AND Scripted host mode ----------------------------------
- ;
- ; Goals:
- ; o Must autodetect caller's baud rate
- ; o Must work correctly for modems reporting true CD and otherwise.
- ; o Must log all activity
- ;
- ; Functions:
- ; o Passworded log-on
- ; o DIR of current directory
- ; o CHDIR command
- ; o UP and DOWNLOADS
- ; o Graphical path display (using P/D TREED program)
- ; o Passworded DOS access (dangerous!)
- ;
- ; Commenced: 10/29/87 R.McG
- ; Updated: 2/--/89 R.McG
- ; --------------------------------------------------------------
- ; Initialize
- ;
- LEGEND "Scripted host mode. Press ESC to exit, and then hangup."
- SET BAUD 1200
- SET PARITY NONE
- SET DATA 8
- SET STOP 1
- SET PORT COM2
- SET ALARM OFF ; Turn off alarm
- SET ATIME 1 ; Set alarm time to 1 second
- SET ASCII UP_LF LF ; Send LFs
- TRANSMIT "~~~+++~~~ATZ^M" ; Initialize modem
- SET MASK ON ; Set 7-bit masking
- LOG MARK ON ; Timestamp logging
- SUBDIR S2 ; Save starting subdir
- CLOG "* Host script loaded"
- GOTO Restart ; Branch around subroutines
- ;
- ; Subroutine: Read from the caller into S9
- ; .. This handles 'disconnect' and timeouts.
- ;
- Read_Comm:
- RGET S9 80 180 ; wait for a connection
- IF NOT CONNECTED ; If modem reports CD dropped
- GOTO Disconnect ; Goto disconnect
- ENDIF
-
- IF NOT SUCCESS ; If timeout on the RGET
- GOTO Timeout ; .. issue message and disconnect
- ENDIF
-
- FIND S9 "NO CARRIER" ; Test for message from modem
- IF FOUND ; If modem didn't report 'CD' true
- GOTO Disconnect ; Goto disconnect
- ENDIF
-
- SET FLAG(0) OFF ; Report to caller
- RETURN ; Return with text in S9
- ;
- ; Timeout on the call
- ;
- Timeout:
- TRAN "^M^J... autodisconnect due to timeout"
- MESSAGE "^M^J... autodisconnect due to timeout"
- GOTO RComm_Exit ; Exit cycle in the usual manner
- ;
- ; Disconnect was reported.
- ;
- Disconnect:
- MESSAGE "^M^JCaller disconnected"
- ;
- ; Read_Comm error exit
- ;
- RComm_Exit:
- SET FLAG(0) ON ; Report to caller
- RETURN ; Return to the caller
- ;
- ; Usages:
- ; S0 -> main password
- ; S1 -> ID
- ; S2 -> Default drive/subdir
- ; S3 -> DOS password
- ; S8 -> File name buffer
- ; S9 -> General read buffer
- ;
- ; Begin the sequence...
- ;
- Restart:
- CHDIR S2 ; Reset to default drive
- SET RECHO OFF ; Turn off echo for us
- CLEAR ; Clear screen
- LOCATE 0,0 ; Set to home
- ;
- ; Go into auto answer (echo off, answer on 3rd)
- ; Also: Return result codes, word form, with CONNECT 1200
- ;
- ;
- MESSAGE "^M^JWaiting..."
- Pause 3 ; Wait 3 seconds
- HANGUP ; HANGUP and leave modem in cmd mode
- PAUSE 3 ; Wait 3 secs
- TRANSMIT "ATE0Q0V1X1S0=2 S7=30 S9=10^M"
- ;
- ; Wait for a connect
- ;
- WAIT_IT_OUT:
- RGET S9 80 180
- IF NOT SUCCESS
- GOTO Wait_IT_Out
- ENDIF
-
- FIND S9 "NO CARRIER"
- IF FOUND
- GOTO Restart
- ENDIF
-
- FIND S9 "CONNECT"
- IF NOT FOUND
- GOTO WAIT_IT_OUT
- ENDIF
-
- ;*** IF NOT CONNECTED
- ;*** GOTO Wait_IT_Out
- ;*** ENDIF
- ;
- ; Connection established: Adjust our linespeed if need be
- ;
- GOSUB AutoBaud ; Change rate according to CONNECT MSG
- ;
- ; Issue a greeting
- ;
- TRAN "^M^JThe Flying Scotsman greets you!!"
- SET RECHO ON ; Turn on echo (back to caller)
- LOG OPEN "HOSTLOG"
- ;
- ; Request an ID
- ;
- ID_Query:
- TRANSMIT "^M^JEnter your ID: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Exit ; .. disconnect and start over
- ENDIF ; ..
-
- SWITCH S9
- CASE "_NULL" ; Test for nothing entered
- TRAN "You must be someone^M^J"
- GOTO Exit ; Don't let noone in
- ENDCASE ; End of ridicule
- ENDSWITCH ; End of ID test
-
- CLOG "* Host mode logon by "*S9
- ;
- ; Request a password
- ;
- TRANSMIT "^M^JEnter your password: "
- LOG SUSPEND
- SET RECHO OFF ; Turn of echo of received text
- SET RDISPLAY OFF ; Turn off echo to console too
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Exit ; .. disconnect and start over
- ENDIF ; ..
-
- LOG RESUME ; Restore logging
- SET RECHO ON ; Restore echo
- SET RDISPLAY ON ; Turn on echo to console again
- ;
- ; Test for the main password
- ;
- SWITCH S9
- CASE S0 ; Test for match with S0
- TRANSMIT "^M^J" ; OK - good password
- ENDCASE ; End match with S0
- DEFAULT ; Not one of the above
- TRANSMIT "Sorry , but you're not authorized."
- GOTO Exit ; And disconnect
- ENDCASE ; End of DEFAULT
- ENDSWITCH
- ;
- ; Now - do something
- ;
- Main_Prompt:
- MESS "^M^JMain prompt" ; Local console indicator
- TRAN "^M^JC)hdir F)ilelist, P)athlist, U)pload, D)ownload, or E)xit: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO EXIT ; .. disconnect and start over
- ENDIF ; ..
-
- SWITCH S9 ; Test the entry
- CASE "C"
- GOTO CHDIR
- ENDCASE
-
- CASE "D"
- GOTO DOWNLOAD
- ENDCASE
-
- CASE "E"
- TRAN "Ok... bye"
- GOTO EXIT
- ENDCASE
-
- CASE "F"
- GOTO FILELIST
- ENDCASE
-
- CASE "P"
- GOTO PATHLIST
- ENDCASE
-
- CASE "U"
- GOTO UPLOAD
- ENDCASE
-
- CASE "X"
- GOTO DOS
- ENDCASE
-
- CASE "OFF"
- TRAN "Ok... bye"
- GOTO EXIT
- ENDCASE
- ;
- ; Default case for typists
- ;
- DEFAULT
- FIND S9 "CHDIR" ; Try for larger
- IF FOUND ; If entry contained "CHDIR"
- GOTO CHDIR
- ENDIF
-
- FIND S9 "DOWN" ; Try for larger
- IF FOUND ; If entry contained 'Down"
- GOTO DOWNLOAD
- ENDIF
-
- FIND S9 "FILE" ; Try for larger
- IF FOUND ; If entry contained 'FILE"
- GOTO FILELIST
- ENDIF
-
- FIND S9 "PATH" ; Try for larger
- IF FOUND ; If entry contained 'PATH"
- GOTO PATHLIST
- ENDIF
-
- FIND S9 "UP" ; Try for larger
- IF FOUND ; If entry contained 'up"
- GOTO UPLOAD
- ENDIF
-
- FIND S9 "DOS" ; Try for larger
- IF FOUND ; If entry contained 'DOS"
- GOTO DOS
- ENDIF
-
- TRAN "^M^JCommand not recognized... try again"
- GOTO Main_Prompt ; If none of the above
- ENDCASE ; End of DEFAULT
- ENDSWITCH
- ;
- ; Can't get here because of the DEFAULT in the SWITCH above
- ;
- TRAN "^M^JThank you veddy much.^M^J"
- GOTO Main_Prompt
- ;
- ; General exit routine - don't GOTO from within a subroutine!!!
- ;
- EXIT:
- CLOG "* Host mode exit"
- LOG CLOSE ; Turn off logging
- MESS "^G" ; Beep to indicate completion
- GOTO Restart ; And start over
- ;
- ; Subroutine: Query for a file name - return in S8
- ;
- File_Query:
- MESS "^M^JFname query" ; Local console indicator
- TRAN "^M^JEnter the file name: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- RETURN ; .. disconnect and start over
- ENDIF ; ..
-
- ASSIGN S8 S9 ; Move fname into another variable
- SWITCH S8
- CASE "_NULL" ; Test for nothing entered
- SET FLAG(1) ON ; Report to caller
- RETURN ; Return right here w/ flag set
- ENDCASE
- ENDSWITCH ; End of ID test
-
- SET FLAG(1) OFF ; Report to caller
- RETURN ; Return to caller
- ;
- ; XMODEM Upload (up from caller)
- ;
- UPLOAD:
- MESS "^M^JUpload from caller"
-
- GOSUB File_Query ; Ask for a file name
- IF FLAG(0) ; If first flag rtns set
- GOTO EXIT ; .. disconnect and start over
- ENDIF ; ..
-
- IF FLAG(1) ; If no file returned
- GOTO Main_Prompt ; .. start over
- ENDIF ; ..
-
-
- ISFILE S8 ; Test for file already
- IF SUCCESS ; If file exists
- TRAN "^M^JFile already exists"
- GOTO UPLOAD ; Ask again
- ENDIF
-
- MESS "^M^JMethod prompt"; Local console indicator
- TRAN "^M^JW)xmodem, X)modem, Y)modem, or K)ermit: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Main_Prompt ; .. disconnect and start over
- ENDIF ; ..
-
- SWITCH S9 ; Test the entry
- CASE "W"
- GETFILE WXMODEM S8
- ENDCASE
- CASE "X"
- GETFILE XMODEM S8
- ENDCASE
- CASE "Y"
- GETFILE YMODEM S8
- ENDCASE
- CASE "K"
- GETFILE KERMIT ; FIle name supplied by caller
- ENDCASE
- DEFAULT
- TRAN "^M^JInvalid transfer selection"
- GOTO Main_Prompt
- ENDCASE
- ENDSWITCH
-
- GOTO EOTransfer ; Report success/failure
- ;
- ; XMODEM Download (down to caller)
- ;
- DOWNLOAD:
- MESS "^M^JDownload to caller"
-
- GOSUB File_Query ; Ask for a file name
- IF FLAG(0) ; If first flag rtns set
- GOTO EXIT ; .. disconnect and start over
- ENDIF ; ..
-
- IF FLAG(1) ; If no file returned,
- GOTO Main_Prompt ; .. start over
- ENDIF ; ..
-
- ISFILE S8 ; Test for file already
- IF NOT SUCCESS ; If file doesn't exist
- TRAN "^M^JFile doesn't exist"
- GOTO DOWNLOAD ; Ask again
- ENDIF
-
- MESS "^M^JMethod prompt"
- TRAN "^MW)xmodem, X)modem, Y)modem, K)ermit, or A)scii: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Main_Prompt ; .. disconnect and start over
- ENDIF ; ..
-
- SWITCH S9 ; Test the entry
- CASE "A"
- SENDFILE ASCII S8
- ENDCASE
- CASE "W"
- SENDFILE WXMODEM S8
- ENDCASE
- CASE "X"
- SENDFILE XMODEM S8
- ENDCASE
- CASE "Y"
- SENDFILE YMODEM S8
- ENDCASE
- CASE "K"
- SENDFILE KERMIT S8
- ENDCASE
- DEFAULT
- TRAN "^M^JInvalid transfer selection"
- GOTO Main_Prompt
- ENDCASE
- ENDSWITCH
-
- GOTO EOTransfer ; Report success/failure
- ;
- ; End of transfer... note result on local console
- ;
- EOTRANSFER:
- IF NOT SUCCESS
- MESS "^M^JTransfer failed"
- ELSE
- MESS "^M^JTransfer OK"
- ENDIF
- GOTO Main_Prompt
- ;
- ; Filelist... awkward... but it works
- ;
- FILELIST:
- MESS "^M^JFilelist command" ; Local console indicator
- TRAN "^M^J Working..." ; May take a moment
-
- DOS "DIR >HOSTTEMP.TXT" ; To a temp file
- TRAN "^M^J" ; Send a c/r
- SENDFILE ASCII "HOSTTEMP.TXT"
- TRAN "^M^J" ; Send a c/r
-
- DOS "DEL HOSTTEMP.TXT" ; Clean up after us
- GOTO Main_Prompt ; And continue
- ;
- ; CHDIR... Query for a path.
- ;
- CHDIR:
- MESS "^M^JCHDIR Command" ; Local console indicator
- TRAN "^M^JEnter the drive:subdirectory: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Main_Prompt ; .. disconnect and start over
- ENDIF ; ..
-
- CHDIR S9 ; Do it.
- GOTO Main_Prompt ; And continue
- ;
- ; Path tree... awkward... but it works
- ;
- PATHLIST:
- MESS "^M^JPathlist command" ; Local console indicator
- TRAN "^M^J Working..." ; May take a moment
-
- DOS "Treed >HOSTTEMP.TXT" ; To a temp file
- TRAN "^M^J" ; Send a c/r
- SENDFILE ASCII "HOSTTEMP.TXT"
- TRAN "^M^J" ; Send a c/r
-
- DOS "DEL HOSTTEMP.TXT" ; Clean up after us
- GOTO Main_Prompt ; And continue
- ;
- ; DOS command: Request a password
- ;
- DOS:
- MESSAGE "^M^JRequesting DOS password"
- LOG SUSPEND ; Turn off logging
- SET RECHO OFF ; .. and don't echo passsword
- SET RDISPLAY OFF ; Turn off echo to console too
-
- TRANSMIT "^M^JEnter the DOS password: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Main_Prompt ; .. disconnect and start over
- ENDIF ; ..
-
- LOG RESUME ; Turn on logging again
- SET RECHO ON ; .. and begin echoing again
- SET RDISPLAY ON ; Turn on echo to console again
- ;
- ; Test for the our password
- ;
- SWITCH S9
- CASE S3 ; Test for match with S3
- TRANSMIT "^M^J" ; OK - good password
- ENDCASE ; End match with S3
- DEFAULT ; Not one of the above
- TRANSMIT "Sorry , but you're not authorized."
- GOTO Main_Prompt ; And continue
- ENDCASE ; End of DEFAULT
- ENDSWITCH
- LOG RESUME
- ;
- ; DOS... Query for a command
- ;
- MESS "^M^JDOS Command" ; Local console indicator
- TRAN "^M^JEnter the command: "
-
- GOSUB Read_Comm ; Read into S9
- IF FLAG(0) ; If first flag rtns set
- GOTO Main_Prompt ; .. disconnect and start over
- ENDIF ; ..
-
- TRAN "^M^J Working..." ; May take a moment
-
- CONCAT S9 ">HOSTTEMP.TXT"
- DOS S9 ; Do it.
-
- TRAN "^M^J" ; Send a c/r
- SENDFILE ASCII "HOSTTEMP.TXT"
- TRAN "^M^J" ; Send a c/r
-
- DOS "DEL HOSTTEMP.TXT" ; Clean up after us
- GOTO Main_Prompt ; And continue
- ;
- ; Auto baudrate detect (according to message in S9)
- ;
- AutoBaud:
- FIND S9 "1200" ; Test for 1200 baud
- IF FOUND ; IF found
- SET BAUD 1200 ; Set to 1200 baud
- RETURN ; We're done.
- ENDIF
-
- FIND S9 "2400" ; Test for 1400 baud
- IF FOUND ; IF found
- SET BAUD 2400 ; Set to 1400 baud
- RETURN ; We're done.
- ENDIF
- ;
- ; None of the above... set to 300
- ;
- SET BAUD 300 ; Set to 1200 baud
- RETURN ; We're done.