home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / HILFEN / MODEM / COMAND28 / HOSETUP.CMD < prev    next >
OS/2 REXX Batch file  |  1993-12-01  |  14KB  |  488 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "HOST Setup ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND HOST setup script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This script, named HOSETUP.CMD, is executed to setup the HOST
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies the ID/passwords to be used.
  12. ; -----------------------------------------------------------------------
  13. ;
  14. ;    Establish a DWINDOW, and change the text display to window default.
  15. ;    .. Save the previous text display attribute, for restoration later.
  16. ;
  17.     DWIND 1,2 22,78     ; Establish scrolling region
  18.     N99 = "_TEXT"           ; Save original text attr
  19.     SET TEXT "_DEFA"        ; Set text attr
  20.     SET FLAG(9) OFF     ; Note if we did any saves
  21. ;
  22. ;    Perform tasks
  23. ;
  24.     GOSUB Init        ; Setup initial values
  25.     GOSUB Main        ; Paint main screen
  26. ;
  27. ;    Exit the script
  28. ;
  29. Escape:
  30. Exit:
  31.     SET TEXT N99        ; Reset text attr finally
  32.     DWINDOW CLEAR        ; Clear any scrolling region
  33.     CLEAR            ; Clear entire text window
  34.     EXIT
  35. ; -----------------------------------------------------------------------
  36. ; ----- Subroutine: Init ->  Set initial values from HOSTDAT
  37. ;    .. NOTE: S29 returns the file name to use for writes to HOSTDAT
  38. ;
  39. Init:
  40.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  41.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for HOST
  42.     S22 = "****"            ; Default logon password
  43.     S23 = "xxxx"            ; Default DOS mode password
  44.     S24 = ""                ; Default Drop-to-DOS command
  45. ;
  46. ;    Replace above values from HOSTDAT if that script exists
  47. ;
  48.     IF ISSC "HOSTDAT"       ; If file exists on dft subdir or COM-AND=
  49.        FCALL "HOSTDAT"      ; .. environment var, execute it
  50.        ENDIF
  51.     RETURN            ; Done init
  52. ; -----------------------------------------------------------------------
  53. ; ----- Subroutine: Save -> Save values in HOSTDAT
  54. ;    .. HOSTDAT is placed in dft subdir; create file if need be
  55. ;
  56. Save:
  57.     ;
  58.     ; Construct a file name on the appropriate directory
  59.     ;
  60.     S1 = ""                 ; Initialize file name string
  61.     IF NOT ISFIL "HOSTDAT"  ; If not on current subdir
  62.        ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
  63.        IF FOUND        ; If environment variable found
  64.           LENGTH S1 N0    ; Get its length
  65.           N0 = N0-1     ; Point to last char in string
  66.           IF not STRCMP S1(n0:n0) "\"
  67.          N0 = N0+1    ; Point after last char
  68.          CONCAT S1(n0) "\"
  69.          ENDIF
  70.           ENDIF
  71.        ENDIF
  72.     S1 = S1&"HOSTDAT"        ; Add the necessary file name
  73.     ;
  74.     ; Open the file, write the file, and close it
  75.     ;
  76.     FOPENO S1 TEXT        ; Open the file name so constructed
  77.     IF NOT SUCCESS
  78.        S0 = "Error opening HOSTDAT file: "*S1
  79.        GOSUB Error        ; Report
  80.        RETURN        ; And we're done
  81.        ENDIF
  82.        ;
  83.        ; Write values we have as of now
  84.        ;
  85.     WRITE "; --- HOST initialization !" ; Write initial comments
  86.     WRITE ";     Updated "*"_DATE"*", at "*"_TIME"*"!"
  87.     WRITE ";!"                         ; Write initial comments
  88.  
  89.     WRITE "S20=`""*S20&"`"!"    ; Write port and speed
  90.     S0 = S21        ; Copy control string
  91.     PRESERVE S0        ; Make it printable
  92.     WRITE "S21=`""*S0&"`"!" ; Write modem control string
  93.     WRITE "S22=`""*S22&"`"!"; Write logon password
  94.     WRITE "S23=`""*S23&"`"!"; Write DOSmode password
  95.     S0 =  "S24=`""*S24&"`"" ; Setup Drop-to-DOS command
  96.     PRESERVE S0        ; Preserve carets, grave, and bangs
  97.     WRITE S0        ; Write DOSmode password
  98.     WRITE "!"               ; Write terminating cr for drop-to-dos line
  99.     WRITE "FRETURN!^Z "     ; Write end of file
  100.        ;
  101.        ; Close the file and we're done
  102.        ;
  103.     SET FLAG(9) ON        ; Note we did ONE save
  104.     FCLOSEO         ; Close the file
  105.     RETURN            ; And we're done
  106. ; -----------------------------------------------------------------------
  107. ; ----- Error:    Open a window, display a message, and wait for keypress
  108. ;    S0 passes the error message
  109. ;
  110. Error:
  111.     WOPEN 10,10,12,70 (cont) Err_Esc
  112.     ATSAY 10,12 (cont) " Error "
  113.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  114.     ATSAY 12,26 (cont) " Press any key to continue "
  115.     ;
  116.     ;    Wait a keypress
  117.     ;
  118.     KEYGET S0        ; Wait for any key
  119.     WCLOSE
  120. Err_Esc:
  121.     RETURN
  122. ; -----------------------------------------------------------------------
  123. ; ----- Subroutine: Main ->  main menu
  124. ;
  125. Main:
  126.     WOPEN 0,0 23,79 (defa) Main_ESC
  127.     ATSAY 0,2 (defa)   " HOST Setup "
  128.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  129. Main100:
  130.     CLEAR            ; Clear window
  131.     LOCATE 2,2
  132.     MESS " 1) Identify modem values"
  133.     MESS " 2) Identify passwords"
  134.     MESS " 3) Define DROP-to-DOS command"
  135.     MESS "_______________________________________"
  136.     MESS " "
  137.     MESS "    Port and speed  is: "*S20
  138.     S0 = S21        ; Copy control string
  139.     PRESERVE S0        ; Make it printable
  140.     MESS "    Modem control   is: "*S0
  141.     MESS "    Logon password  is: "*S22
  142.     MESS "    DOS password    is: "*S23
  143.     MESS "    Drop to DOS command is: "
  144.     S0 = S24
  145.     PRESERVE S0        ; Make it printable
  146.     MESS "    "*S0
  147.     MESS "_______________________________________"
  148.     MESS " "
  149.     MESS "Select item (carriage return = exit): "
  150. ;
  151. ;    Wait for a keypress
  152. ;
  153.     GET S0 1        ; Wait for it
  154.     SWITCH S0        ; Act according to keyget
  155.       CASE "1"
  156.            GOSUB Modem
  157.            ENDCASE
  158.       CASE "2"
  159.            GOSUB Password
  160.            ENDCASE
  161.       CASE "3"
  162.            GOSUB DropDOS
  163.            ENDCASE
  164.       CASE "_NULL"          ; c/r alone is exit
  165.            WCLOSE        ; Close window...
  166.            RETURN        ; Leave Main routine
  167.            ENDCASE
  168.       DEFAULT        ; None of the above
  169.            SOUND 100,100    ; Bronx cheer
  170.            ENDCASE
  171.       ENDSWITCH
  172.     GOTO Main100        ; Repaint screen and ask again
  173. ; -----------------------------------------------------------------------
  174. ; ----- Subroutine: Modem ->  modem values
  175. ;
  176. Modem:
  177.     WOPEN 0,0 23,79 (defa) Main_ESC
  178.     ATSAY 0,2 (defa)   " HOST Modem "
  179.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  180. MODE100:
  181.     CLEAR            ; Clear window
  182.     LOCATE 2,2
  183.     MESS " 1) Identify modem port"
  184.     MESS " 2) Identify modem speed"
  185.     MESS " 3) Identify modem control string"
  186.     MESS "_______________________________________"
  187.     MESS " "
  188.     MESS "    Port and speed  is: "*S20
  189.     S0 = S21        ; Copy control string
  190.     PRESERVE S0        ; Make it printable
  191.     MESS "    Modem control   is: "*S0
  192.     MESS "_______________________________________"
  193.     MESS " "
  194.     MESS "Select item (carriage return = previous): "
  195. ;
  196. ;    Wait for a keypress
  197. ;
  198.     GET S0 1        ; Wait for it
  199.     SWITCH S0        ; Act according to keyget
  200.       CASE "1"
  201.            GOSUB Modem_Port
  202.            ENDCASE
  203.       CASE "2"
  204.            GOSUB Modem_Speed
  205.            ENDCASE
  206.       CASE "3"
  207.            GOSUB Modem_Control
  208.            ENDCASE
  209.       CASE "_NULL"          ; c/r alone is exit
  210.            WCLOSE        ; Close window...
  211.            RETURN        ; Leave Main routine
  212.            ENDCASE
  213.       DEFAULT        ; None of the above
  214.            SOUND 100,100    ; Bronx cheer
  215.            ENDCASE
  216.       ENDSWITCH
  217.     GOTO MODE100        ; Repaint screen and ask again
  218. ;
  219. ;    Escape during main
  220. ;
  221. Main_Esc:
  222.     S0 = ""                 ; Blank entry
  223.     RETURN            ; And execute it
  224. ;
  225. ; ----- Subroutine: Modem_port -> Set default modem port to use
  226. ;
  227. Modem_Port:
  228.     WOPEN 0,0 23,79 (defa) Main_ESC
  229.     ATSAY 0,2 (defa)   " HOST Port "
  230.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  231.     LOCATE 2,2
  232.  
  233.     MESS "The HOST is currently directed to run on the port: "*S20(0:3)
  234.     MESS " "
  235.     MESS "The HOST may use any port COM1 through COM4.  If you wish to use a port"
  236.     MESS "other than the above, enter it here."
  237.     MESS " "
  238.     MESS "Port (carriage rtn alone accepts): "
  239. ;
  240. ;    Wait for entry, and interpret
  241. ;
  242.     S0 = "    "             ; Default value
  243.     GET S0 4        ; Wait for a char
  244.     IF NULL S0 GOTO MOPOEND ; Nothing entered
  245.     IF NOT FIND S0(0:2) "com" GOTO MOPOERR
  246.     IF S0(3) LT 1 or S0(3) GT 4 GOTO MOPOERR
  247. ;
  248. ;    Save the value
  249. ;
  250.     S20(0:3) = S0        ; Set new value
  251.     GOSUB Save        ; Save the new value
  252. ;
  253. ;    End of window
  254. ;
  255. MOPOEND:
  256.     WCLOSE
  257.     RETURN
  258. ;
  259. ;    Error in input string
  260. ;
  261. MOPOERR:
  262.     SOUND 100,100        ; Bronx cheer
  263.     GOTO Modem_Port     ; And try again
  264. ;
  265. ; ----- Subroutine: Modem_Speed -> Set default modem speed to use
  266. ;
  267. Modem_Speed:
  268.     WOPEN 0,0 23,79 (defa) Main_Esc
  269.     ATSAY 0,2 (defa)   " HOST Speed "
  270.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  271.     LOCATE 2,2
  272.  
  273.     MESS "The HOST currently defaults to wait for call at: "*S20(5:8)*" baud"
  274.     MESS " "
  275.     MESS "The HOST may wait for a call at any rate you wish.  If you wish to use a"
  276.     MESS "speed other than the above, enter it here. Legitimate speeds are: 300,"
  277.     MESS "1200, 2400, 4800, 9600, and 19.2"
  278.     MESS " "
  279.     MESS "Speed (carriage rtn alone accepts): "
  280. ;
  281. ;    Wait for entry, and interpret
  282. ;
  283.     S0 = "    "             ; Default value
  284.     GET S0 4        ; Wait for a char
  285.     IF NULL S0 GOTO MOSPEND ; Nothing entered
  286.     IF NOT FIND "300  300120024004800960019.2" S0(0:2) N0 GOTO MOSPERR
  287.     IF 4*(N0/4) ne N0 GOTO MOSPERR
  288. ;
  289. ;    Save the value
  290. ;
  291.     S20(5:8) = S0        ; Set new value
  292.     GOSUB Save        ; Save the new value
  293. ;
  294. ;    End of window
  295. ;
  296. MOSPEND:
  297.     WCLOSE
  298.     RETURN
  299. ;
  300. ;    Error in input string
  301. ;
  302. MOSPERR:
  303.     SOUND 100,100        ; Bronx cheer
  304.     GOTO Modem_Speed    ; And try again
  305. ;
  306. ; ----- Subroutine: Modem_Control -> Set the modem initialization string to use
  307. ;
  308. Modem_Control:
  309.     WOPEN 0,0 23,79 (defa) Main_Esc
  310.     ATSAY 0,2 (defa)   " HOST Control "
  311.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  312.     LOCATE 2,2
  313.  
  314.     MESS "The HOST currently is set to initialize the modem with: "
  315.     S0 = S21        ; Fetch value
  316.     PRESERVE S0        ; Preserve for printing
  317.     MESS S0         ; Display string
  318.     MESS " "
  319.     MESS "The initialization string must be correct for your modem.  Please refer to "
  320.     MESS "the documentation that came with your modem.  The init string will probably"
  321.     MESS "begin with modem attention (default 'AT'), MUST enable autoanswer, and will"
  322.     MESS "probably end with a carriage return.  "
  323.     MESS " "
  324.     MESS "Please note: Enter '^^A' through '^^Z' to indicate control chars, '^^^^' for"
  325.     MESS "a single caret, '!!' for a carriage return (or '^^M') and '!!!!' for a single"
  326.     MESS "exclamation point."
  327.     MESS " "
  328.     MESS "Control string (carriage return accepts): "
  329. ;
  330. ;    Wait for entry, and interpret
  331. ;
  332.     S0 = "    "             ; Default value
  333.     GET S0 50        ; Wait for a char
  334.     IF NULL S0 GOTO MOCOEND ; Nothing entered
  335. ;
  336. ;    Save the value
  337. ;
  338.     S21 = S0        ; Set new value
  339.     GOSUB Save        ; Save the new value
  340. ;
  341. ;    End of window
  342. ;
  343. MOCOEND:
  344.     WCLOSE
  345.     RETURN
  346. ; -----------------------------------------------------------------------
  347. ; ----- Subroutine: Password ->  Update passwords used by HOST
  348. ;
  349. Password:
  350.     WOPEN 0,0 23,79 (defa) Main_Esc
  351.     ATSAY 0,2 (defa)   " HOST passwords "
  352.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  353. SUBD100:
  354.     CLEAR
  355.     LOCATE 2,2
  356.     MESS " 1) Identify LOGON password"
  357.     MESS " 2) Identify DOS mode password"
  358.  
  359.     MESS "__________________________________"
  360.     MESS " "
  361.     MESS "    Logon password  is: "*S22
  362.     MESS "    DOS password    is: "*S23
  363.     MESS "__________________________________"
  364.     MESS " "
  365.     MESS "Select item (carriage return = previous): "
  366. ;
  367. ;    Wait for a keypress
  368. ;
  369.     GET S0 1        ; Wait for it
  370.     SWITCH S0        ; Act according to keyget
  371.       CASE "1"
  372.            GOSUB Logon
  373.            ENDCASE
  374.       CASE "2"
  375.            GOSUB DOS
  376.            ENDCASE
  377.       CASE "_NULL"          ; c/r alone is exit
  378.            WCLOSE        ; Close window...
  379.            RETURN        ; Leave Main routine
  380.            ENDCASE
  381.       DEFAULT        ; None of the above
  382.            SOUND 100,100    ; Bronx cheer
  383.            ENDCASE
  384.       ENDSWITCH
  385.     GOTO Subd100        ; Repaint screen and ask again
  386. ;
  387. ; ----- Subroutine: Logon -> Set the logon password
  388. ;
  389. Logon:
  390.     WOPEN 0,0 23,79 (defa) Main_Esc
  391.     ATSAY 0,2 (defa)   " HOST Logon password "
  392.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  393.     LOCATE 2,2
  394.  
  395.     MESS "The Logon password is: "
  396.     MESS S22
  397.     MESS " "
  398.     MESS "The logon password must be set for any HOST access.  Callers may use any ID"
  399.     MESS "but MUST specify this password to have access."
  400.     MESS " "
  401.     MESS "HOST Logon password (carriage return accepts): "
  402. ;
  403. ;    Wait for entry, and interpret
  404. ;
  405.     S0 = "    "             ; Default value
  406.     GET S0 60        ; Wait for entry
  407.     IF NULL S0 GOTO LOPAEND ; Nothing entered
  408. ;
  409. ;    Save the value
  410. ;
  411.     S22 = S0        ; Set new value
  412.     GOSUB Save        ; Save the new value
  413. ;
  414. ;    End of window
  415. ;
  416. LOPAEND:
  417.     WCLOSE
  418.     RETURN
  419. ;
  420. ; ----- Subroutine: DOS -> Set the DOS mode password
  421. ;
  422. DOS:
  423.     WOPEN 0,0 23,79 (defa) Main_Esc
  424.     ATSAY 0,2 (defa)   " HOST DOS password "
  425.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  426.     LOCATE 2,2
  427.  
  428.     MESS "The DOS mode password is: "
  429.     MESS S23
  430.     MESS " "
  431.     MESS "The DOS password must be set for access to DOS mode through HOST.  This "
  432.     MESS "password is a second password - not the same as the Logon password."
  433.     MESS " "
  434.     MESS "HOST DOS password (carriage return accepts): "
  435. ;
  436. ;    Wait for entry, and interpret
  437. ;
  438.     S0 = "    "             ; Default value
  439.     GET S0 60        ; Wait for entry
  440.     IF NULL S0 GOTO DOPAEND ; Nothing entered
  441. ;
  442. ;    Save the value
  443. ;
  444.     S23 = S0        ; Set new value
  445.     GOSUB Save        ; Save the new value
  446. ;
  447. ;    End of window
  448. ;
  449. DOPAEND:
  450.     WCLOSE
  451.     RETURN
  452. ;
  453. ; ----- Subroutine: DropDOS -> Define the DROP-to-DOS mode command
  454. ;
  455. DropDOS:
  456.     WOPEN 0,0 23,79 (defa) Main_Esc
  457.     ATSAY 0,2 (defa)   " HOST DropDOS command "
  458.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  459.     LOCATE 2,2
  460.  
  461.     MESS "The Drop-to-DOS command currently is: "
  462.     S0 = S24
  463.     PRESERVE S0        ; Make it printable
  464.     MESS S0
  465.     MESS " "
  466.     MESS "The Drop-To-DOS command must execute a function such as DOORWAY for a"
  467.     MESS "drop into DOS.  This feature is not available if the command here is"
  468.     MESS "set null.  If this feature IS not null, the command here will be built"
  469.     MESS "into a temporary batch file and executed on request (DOS passworded)."
  470.     MESS " "
  471.     MESS "HOST Drop-to-DOS command (you MUSE enter new value): ^M^J"
  472. ;
  473. ;    Wait for entry, and interpret
  474. ;
  475.     S0 = "    "             ; Default value
  476.     GET S0 70        ; Wait for entry
  477. ;
  478. ;    Save the value
  479. ;
  480.     S24 = S0        ; Set new value
  481.     GOSUB Save        ; Save the new value
  482. ;
  483. ;    End of window
  484. ;
  485. DRDOEND:
  486.     WCLOSE
  487.     RETURN
  488.