home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac_os2 / zoc195.zip / INSTALL.FIL / SCRIPT / REXXHOST < prev   
Text File  |  1994-09-04  |  11KB  |  413 lines

  1. /* REXX */
  2.  
  3. /* IMPORTANT !!! Set ASC DELAY in options transfer to 0 */
  4. /* IMPORTANT !!! Set CD Valid in options transfer ON */
  5.  
  6.     /* use this to debug script
  7.     TRACE A */
  8.     
  9.     ADDRESS ZOC
  10.     
  11.      /* load HOSTOPTS, if available */      
  12.     LOADOPTS hostopts
  13.     DELAY 3
  14.  
  15.     /* check, whether valid cd option is set */
  16.     IF zoccarrier() == 'N/A' THEN
  17.     DO
  18.         WRITE '"Please enable CD Valid in OPTIONS SERIAL^M^J^M^J"'
  19.         EXIT
  20.     END
  21.  
  22.     /* give the other side an echo */
  23.     SETHOST 0
  24.     
  25.     /* use a timeout of 60 for any input */
  26.     TIMEOUT 60
  27.  
  28.     /* switch our modem into answer mode */
  29.     WRITE '^[[2J^[[1H'
  30.     SEND 'ATS0=1^M^J'
  31.  
  32.     /* set variables with default values - may be changed */
  33.     curdrive= 'c:'
  34.     curdir= '\'
  35.     guestdrive= ''
  36.     guestdir= 'script\guest\'
  37.     superpass= '"secret"'
  38.     guestpass= '"guest"'
  39.  
  40.     /* ask for passwords */
  41.     ASK '"Supervisor password"' superpass
  42.     superpass= zocresult()
  43.     ASK '"Guest password"' guestpass
  44.     guestpass= zocresult()
  45.  
  46.  
  47.  
  48. /* -------------------------------------------------------------- */
  49. /* wait for connect, set serial speed and check password          */
  50. /* -------------------------------------------------------------- */
  51. allover:
  52.  
  53.     /* put infos on screen */
  54.     WRITE '^[[2J^[[1H'
  55.     WRITE '"Waiting for call ...^M^J^M^J"'
  56.  
  57.     
  58.     WAIT 'CONNECT'                    /* wait for connect */
  59.     DO WHILE rc <> 0
  60.         WAIT 'CONNECT'
  61.     END
  62.  
  63.     WAIT '^M'
  64.     
  65.     CALL wsend '^[[2J^[[1H'
  66.     CALL wsend '"Press BACKSPACE key to start host ...^M^J"'
  67.     WAIT '^H'
  68.     
  69.     IF zoccarrier()=='NO CARRIER' | rc <> 0 THEN SIGNAL endit
  70.  
  71.     /* show welcome screen */
  72.     CALL wsend '^[[2J^[[1H'
  73.     CALL welcome
  74.     CALL wsend '"Enter Password: "'
  75.  
  76.     WAIT '^M'
  77.     pass= zoclastline()
  78.     pass= STRIP(pass)
  79.  
  80.     IF pass= superpass THEN
  81.         status= 'super'
  82.     ELSE
  83.     IF pass= guestpass THEN
  84.     DO
  85.         status= 'guest'
  86.         curdrive= guestdrive
  87.         curdir= guestdir
  88.     END
  89.     ELSE
  90.     DO
  91.         CALL wsend '^M^J^M^J'
  92.         CALL wsend '"Sorry, authorization failed !"'
  93.         SIGNAL endit
  94.     END
  95.  
  96.  
  97. /* -------------------------------------------------------------- */
  98. /* print a new menu and ask choice                                */
  99. /* -------------------------------------------------------------- */
  100. menu:
  101.     SETHOST 1
  102.     choice= ' '
  103.  
  104.     CALL showmenu
  105.     CALL wsend '^[[0m'
  106.     CALL wsend '^[[19;12H'
  107.     
  108.     IF status= 'super' THEN
  109.         CALL wsend '"Your Choice (C/F/S/T/U/D/H/G): "'
  110.     ELSE
  111.         CALL wsend '"Your Choice (F/T/U/D/G): "'
  112.  
  113.  
  114. menuask:
  115.     WAIT '^M'
  116.  
  117.     /* if the carrier was lost, restart the whole story */
  118.     IF zoccarrier()=='NO CARRIER' THEN SIGNAL endit
  119.  
  120.     /* if input timed out redo input */
  121.     IF rc <> 0 THEN SIGNAL menuask
  122.  
  123.     /* text cosmetics for user input string */
  124.     choice= zoclastline()
  125.     choice= STRIP(choice)
  126.  
  127.     /* change directory */
  128.     IF (choice='C' | choice='c') & status= 'super' THEN CALL changedir
  129.  
  130.     /* show files in directory */
  131.     IF choice='F' | choice='f' THEN CALL showdir ddir
  132.  
  133.     /* search for entry */
  134.     IF (choice='S' | choice='s') & status= 'super' THEN CALL search
  135.  
  136.     /* type file */
  137.     IF choice='T' | choice='t' THEN CALL type
  138.  
  139.     /* zmodem upload */
  140.     IF choice='U' | choice='u' THEN CALL upload
  141.  
  142.     /* zmodem download */
  143.     IF choice='D' | choice='d' THEN CALL download
  144.  
  145.     /* shutdown host */
  146.     IF (choice='H' | choice='h') & status= 'super' THEN CALL shutdown
  147.  
  148.     /* goodbye */
  149.     IF choice='G' | choice='g' THEN
  150.     DO
  151.         CALL wsend '^[[21;12H'
  152.         CALL wsend '"Have a nice day ...^M^J"'
  153.         CALL endit
  154.     END
  155.     
  156.     SIGNAL menu
  157.  
  158.  
  159. endit:
  160.     SETHOST 0
  161.     HANGUP
  162.     DELAY 5
  163.     SIGNAL allover
  164.  
  165.  
  166.  
  167. /* ============================================================== */
  168. /* SUBROUTINES                                                    */
  169. /* ============================================================== */
  170.  
  171. /* -------------------------------------------------------------- */
  172. /* change current directory                                       */
  173. /* -------------------------------------------------------------- */
  174. changedir:
  175.     
  176.     CALL wsend '^[[21;12H'
  177.     CALL wsend '"Enter full directory path: "'
  178.     WAIT '^M'
  179.  
  180.     IF rc= 0 THEN
  181.     DO
  182.         curdir= zoclastline()
  183.         IF RIGHT(curdir, 1) \= '\' THEN curdir= curdir'\'
  184.         IF SUBSTR(curdir, 2, 1) = ':' THEN
  185.         DO
  186.             curdrive= SUBSTR(curdir, 1, 2)
  187.             curdir= RIGHT(curdir, length(curdir)-2)
  188.         END
  189.         IF SUBSTR(curdir, 1, 1) \= '\' THEN curdir= '\'curdir
  190.     END
  191.     
  192.     RETURN
  193.  
  194.  
  195. /* -------------------------------------------------------------- */
  196. /* show current directory                                         */
  197. /* -------------------------------------------------------------- */
  198. showdir: 
  199.     ADDRESS CMD '"dir 'curdrive||curdir' >shellout.tmp"'
  200.     CALL wsend '^[[2J^[[1H'
  201.     UPLOAD a1 'shellout.tmp' 
  202.     ADDRESS CMD 'del shellout.tmp'
  203.     CALL wsend '^M^J'
  204.     CALL wsend '"Press Enter to return..."'
  205.     WAIT '^M'
  206.     RETURN
  207.  
  208.  
  209. /* -------------------------------------------------------------- */
  210. /* search on current drive                                        */
  211. /* -------------------------------------------------------------- */
  212. search: 
  213.     CALL wsend '^[[21;12H'
  214.     CALL wsend '"Enter filename to search on drive 'curdrive' "'
  215.     WAIT '^M'
  216.     
  217.     IF rc= 0 THEN
  218.     DO
  219.         sname= zoclastline()
  220.         sname= STRIP(sname)
  221.     END
  222.     ELSE
  223.         RETURN
  224.     
  225.     CALL wsend '^[[22;12H'
  226.     CALL wsend '"Searching on drive 'curdrive', please wait ..."'
  227.     ADDRESS CMD '"dir 'curdrive'\'sname' /s >shellout.tmp"'
  228.     CALL wsend '^[[2J^[[1H'
  229.     UPLOAD a1 'shellout.tmp' 
  230.     ADDRESS CMD 'del shellout.tmp'
  231.     CALL wsend '^M^J'
  232.     CALL wsend '"Press Enter to return..."'
  233.     WAIT '^M'
  234.     RETURN
  235.  
  236.  
  237. /* -------------------------------------------------------------- */
  238. /* type file                                                      */
  239. /* -------------------------------------------------------------- */
  240. type: 
  241.     CALL wsend '^[[21;12H'
  242.     CALL wsend '"Enter filename to type: 'curdrive||curdir'"'
  243.     WAIT '^M'
  244.     
  245.     IF rc= 0 THEN
  246.     DO
  247.         sname= zoclastline()
  248.         sname= STRIP(sname)
  249.     END
  250.     ELSE
  251.         RETURN
  252.     
  253.     ADDRESS CMD '"type 'curdrive||curdir||sname' >shellout.tmp"'
  254.     CALL wsend '^[[2J^[[1H'
  255.     UPLOAD a1 'shellout.tmp' 
  256.     ADDRESS CMD 'del shellout.tmp'
  257.     CALL wsend '^M^J'
  258.     CALL wsend '"Press Enter to return..."'
  259.     WAIT '^M'
  260.     RETURN
  261.  
  262.  
  263. /* -------------------------------------------------------------- */
  264. /* upload file                                                    */
  265. /* -------------------------------------------------------------- */
  266. upload:
  267.     CALL wsend '^[[21;12H'
  268.     CALL wsend '"Please start your Zmodem upload"'
  269.     CALL wsend '^[[22;12H'
  270.     
  271.     DOWNLOAD z curdrive||curdir 
  272.     RETURN
  273.  
  274.  
  275. /* -------------------------------------------------------------- */
  276. /* download file                                                  */
  277. /* -------------------------------------------------------------- */
  278. download:
  279.     CALL wsend '^[[21;12H'
  280.     CALL wsend '"Enter filename to receive: 'curdrive||curdir'"'
  281.     WAIT '^M'
  282.     CALL wsend '^[[22;12H'
  283.  
  284.     IF rc= 0 THEN
  285.     DO
  286.         file= zoclastline()
  287.         file= STRIP(file)
  288.     END
  289.     ELSE
  290.         RETURN
  291.  
  292.     IF file \= '' THEN
  293.         UPLOAD z curdrive||curdir||file
  294.     RETURN
  295.  
  296.  
  297. /* -------------------------------------------------------------- */
  298. /* Shutdown host                                                  */
  299. /* -------------------------------------------------------------- */
  300. shutdown:
  301.     CALL wsend '^[[21;12H'
  302.     CALL wsend '"Hostmode will be quit now ...^M^J"'
  303.     SETHOST 0
  304.     HANGUP
  305.     DELAY 5
  306.     CALL wsend 'ATS0=0^M^J'
  307.     EXIT
  308.  
  309.  
  310. /* ============================================================== */
  311. /* HELP-FUNCTIONS */
  312. /* ============================================================== */
  313.  
  314. /* -------------------------------------------------------------- */
  315. /* draw one menu-point with ARG(line, col, shortcut, name)        */
  316. /* -------------------------------------------------------------- */
  317. menupoint:
  318.     
  319.     CALL wsend '"^[['ARG(1)';'ARG(2)'H"'
  320.     CALL wsend '"^[[1;37;47m┌───^[[0;30;47m┐"'
  321.     CALL wsend '"^[[1;37m┌────────────────────^[[0;30;47m┐^[[40m"'
  322.  
  323.     CALL wsend '"^[['ARG(1)+1';'ARG(2)'H"'
  324.     CALL wsend '"^[[1;37;47m│ ^[[0;34;47m'ARG(3)' ^[[30m│"'
  325.     CALL wsend '"^[[1;37m│^[[0;30;47m'ARG(4)'│^[[40m"'
  326.  
  327.     CALL wsend '"^[['ARG(1)+2';'ARG(2)'H"'
  328.     CALL wsend '"^[[1;37;47m└^[[0;30;47m───┘"'
  329.     CALL wsend '"^[[1;37m└^[[0;30;47m────────────────────┘^[[40m"'
  330.  
  331.     RETURN
  332.  
  333.  
  334. /* -------------------------------------------------------------- */
  335. /* draw one info-point with ARG(line, col, text)                  */
  336. /* -------------------------------------------------------------- */
  337. infopoint:
  338.     
  339.     CALL wsend '"^[['ARG(1)';'ARG(2)'H"'
  340.     CALL wsend '"^[[1;37;47m┌──────────────────────────────────"'
  341.     CALL wsend '"──────────────────────────^[[0;30;47m┐"'
  342.  
  343.     CALL wsend '"^[['ARG(1)+1';'ARG(2)'H"'
  344.     CALL wsend '"^[[1;37;47m│ ^[[0;30;47m'ARG(3)' ^[[30m│"'
  345.     
  346.     CALL wsend '"^[['ARG(1)+2';'ARG(2)'H"'
  347.     CALL wsend '"^[[1;37;47m└^[[0;30;47m────────────────────────"'
  348.     CALL wsend '"────────────────────────────────────┘"'
  349.  
  350.     RETURN
  351.  
  352.  
  353. /* -------------------------------------------------------------- */
  354. /* draw the whole menu with alle menu- and info-points            */
  355. /* -------------------------------------------------------------- */
  356. showmenu:
  357.     CALL wsend '"^[[2J^[[1H"'
  358.  
  359.     IF status= 'super' THEN
  360.     DO
  361.         CALL menupoint 2,  10, 'C', ' (C)hange directory '
  362.         CALL menupoint 5,  10, 'F', ' Show dir (F)iles   ' 
  363.         CALL menupoint 8,  10, 'S', ' (S)earch a file    '
  364.         CALL menupoint 11, 10, 'T', ' (T)ype a file      ' 
  365.         CALL menupoint 2,  45, 'U', ' (U)pload a file    '
  366.         CALL menupoint 5,  45, 'D', ' (D)ownload a file  '
  367.         CALL menupoint 8,  45, 'H', ' Shutdown (H)ost    '
  368.         CALL menupoint 11, 45, 'G', ' (G)oodbye          '
  369.      END
  370.     ELSE
  371.     DO
  372.         CALL menupoint 3,  10, 'F', ' Show dir (F)iles   ' 
  373.         CALL menupoint 6,  10, 'T', ' (T)ype a file      ' 
  374.         CALL menupoint 3,  45, 'U', ' (U)pload a file    '
  375.         CALL menupoint 6,  45, 'D', ' (D)ownload a file  '
  376.         CALL menupoint 10, 27, 'G', ' (G)oodbye          '
  377.     END
  378.     
  379.     curpath= curdrive||curdir
  380.     CALL infopoint 15, 10, '^[[0;34;47mCurrent Dir:^[[30m  'overlay(curpath,'                                            ')
  381.     RETURN
  382.  
  383.  
  384. /* -------------------------------------------------------------- */
  385. /* draw beginning text                                            */
  386. /* -------------------------------------------------------------- */
  387. welcome:
  388.     CALL wsend '"                 ^M^J"'
  389.     CALL wsend '" ___  ___ ___    ^M^J"'
  390.     CALL wsend '"|__ || _ | __|   ^M^J"'
  391.     CALL wsend '" / /_||_|| |_     ZOC RexxHost-Script V1.0^M^J"'
  392.     CALL wsend '"|____|___|___|   ^M^J^M^J^M^J"'
  393.  
  394.     RETURN
  395.  
  396.  
  397. /* -------------------------------------------------------------- */
  398. /* send and write at the same time                                */
  399. /* -------------------------------------------------------------- */
  400. wsend:
  401.  
  402.     SEND ARG(1)
  403.     WRITE ARG(1)
  404.  
  405.     RETURN
  406.  
  407.  
  408.  
  409.  
  410.  
  411. /* END OF REXX-MODULE */
  412.  
  413.