home *** CD-ROM | disk | FTP | other *** search
/ Inside Multimedia 1995 April / IMM0495.ISO / share / vorstell / zoc205 / install.fil / SCRIPT / REXXHOST < prev    next >
Text File  |  1995-01-02  |  11KB  |  438 lines

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