home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac_os2 / zoc195.zip / INSTALL.FIL / SCRIPT / HOSTS / HOSTZOC2 next >
Text File  |  1994-04-25  |  13KB  |  386 lines

  1. #
  2. # This script is a modification of my MINIHOST script, which
  3. # was/is rather crude. This version was modified by Mike
  4. # Nowostawsky (thanks) and is provided as is.
  5. #                                    Markus Schmidt, 4/94
  6.  
  7. // set debug off = 0, on = 1
  8. debug 0
  9. #######################################################################
  10. #                                                                     #
  11. # README!                                                             #
  12. #                                                                     #
  13. #   This script is a small host.                         #
  14. #   It takes incoming calls and lets the user change directory,       #
  15. #   show directories and send/receive files.                          #
  16. #                                                                     #
  17. #   Here are a few functions given to the remote caller in this       #
  18. #   script:                                                           #
  19. #      -Change-dir     (Should specify EXACT dir WITH path)           #
  20. #      -Dir            (Of CURRENT directory)                         #
  21. #      -UpLoad         (Set as Z-modem d/l)                           #
  22. #      -DownLoad       (Set as Z-modem u/l)                           #
  23. #      -Beep host      (Limited chat:see documentation inside script) #
  24. #      -Shell to os/2  (VERY powerful: use with caution)              #
  25. #      -Exit                                                          #
  26. #                                                                     #
  27. #    ORIGINALLY 'MINIHOST' (from Markus Schmidt):                     #
  28. #    This script has been modified to allow minimal functionality     #
  29. #      as a host. QUITE useful to hook into a home system from a      #
  30. #      remote location to view, u/l, d/l files. NOT a bonafide host.  #
  31. #      Feel free to modify to add more functionality/versatility.     #
  32. #                                                                     #
  33. #    THINGS TO CONSIDER/KNOW/KEEP IN MIND:                            #
  34. #      -code have been added to check for disconnects in unexpected   #
  35. #       areas, BUT they may still cause lockups depending on strange/ #
  36. #       various circumstances. Test with your h/w, as this will vary. #
  37. #      -read the comments in this script, as some areas must be       #
  38. #       customized to your system.                                    #
  39. #      -when 2400 baud modems log into this host script a 'garbage'   #
  40. #       character seems to get sent to the host side. Have not found  #
  41. #       how to get rid of it other than having the caller hit the     #
  42. #       BACKSPACE key (quite strange). This has to be done or the     #
  43. #       password will end up being incorrect (tags garbage char       #
  44. #       onto front of it).                                            #
  45. #      -script has been coded to use ANSI emulation, and ZMODEM       #
  46. #       transfer protocol (You can customize your emulation in the 2  #
  47. #       options files you create. d/l, u/l protocol can be customized #
  48. #       in this script: in the u/l d/l subroutines)                   #
  49. #                                                                     #
  50. #    GOOD LUCK!                                                       #
  51. #    (Mike Nowostawsky)                                               #
  52. #    BTW, I am simply a user of ZOC and have given this out as is.    #
  53. #    I take no responsibility for ANY problems that may occur as a    #
  54. #    result of it's use. If you find it useful, good!                 #
  55. #    Also, if you enhance this script and get it working better,      #
  56. #    by all means share it with the rest of us ZOC users <g>.         #
  57. #                                                                     #
  58. #######################################################################
  59.  
  60. // *******************
  61. // ***** NOTE!!! *****
  62. // *******************
  63. // This SCRIPT will set the following options by loading 2 option files
  64. // one BEFORE modem connect (initially) and then one AFTER modem connect. 
  65. // The first option file is then reloaded again after disconnect to reset 
  66. // host mode's SEND ECHO, otherwise an infinite loop occurs.
  67. //
  68. // These option files should be created from the STANDARD option file 
  69. // and put in a particular directory on your system and THAT 
  70. // directory should be used in this script (i.e. modify ALL 'LOADOPTS' 
  71. // commands in this script accordingly).
  72. //
  73. // These are the settings that I changed using the STANDARD option file 
  74. // as a starting point and that worked best for MY SYSTEM (yours may vary): 
  75. //
  76. // **Before connect, HOSTBEF option file settings:
  77. //    - SERIAL:-38400 
  78. //               -RTS/CTS handshake (*ON* - check mark)
  79. //     - TRANSFER:-ASCII Upload:-CR -> CR/LF (*ON* - check mark)
  80. //                 -char delay = 0 (faster u/l, d/l)
  81. //    - MODEM:-Dial prefix = ATDT
  82. //
  83. // **After connect, HOSTAFT option file settings:
  84. //    - SERIAL:-38400
  85. //         -RTS/CTS handshake (*ON* - check mark)
  86. //    - TERMINAL:-Incoming CR to CR/LF (*ON* - check mark) 
  87. //           -Local echo (half duplex) (*ON* - check mark) 
  88. //           -Send echo (host mode) (*ON* - check mark)
  89. //     - TRANSFER:-ASCII Upload:-CR -> CR/LF (*ON* - check mark)
  90. //                 -char delay = 0 (faster u/l, d/l)
  91. //    - MODEM:-Dial prefix = ATDT
  92.  
  93. :start
  94.     
  95. // load initial "HOSTBEF" options file
  96. // Set modem to auto answer and script to exact mode
  97.         loadopts "C:\zoc\options\hostbef"
  98.     delay 3                    ;//delay to let command complete
  99.  
  100.     send "ATS0=1^M"        
  101.     delay 2        
  102.  
  103.     exact 1
  104.  
  105. // ENTRY 
  106. // * wait for connect 
  107. // * ask for password
  108. // * hangup if pw wrong
  109.  
  110.     cls
  111.     send "Waiting for call..."
  112.  
  113. :conwait
  114.     wait CONNECT        ;// wait for connect
  115.     ifbrk goto conwait    
  116.     wait "^M"        ;// the stuff after connect is the speed
  117.  
  118. // check for various dropped connections
  119.     ifbrk goto endit    
  120.      compa "%lastline%" with "+++"
  121.            ifin goto endit
  122.     compa "%lastline%" with "NO CARRIER"
  123.            ifin goto endit
  124.  
  125. // show welcome screen
  126.  
  127.     send "^[[2J"        ;// clear screen on remote/caller side
  128.  
  129.     send "Press BACKSPACE key to start host..."
  130.     wait "^H"        ;// wait for BACKSPACE to clear garbage character    
  131.  
  132. // check for various dropped connections
  133.     ifbrk goto endit    
  134.      compa "%lastline%" with "+++"
  135.            ifin goto endit
  136.     compa "%lastline%" with "NO CARRIER"
  137.            ifin goto endit
  138.  
  139.     timeout 60
  140.     send "^[[2J"        ;// clear screen on remote/caller side
  141.     send "Welcome !! ^M^J^M^J"
  142.     send "Enter Password : "
  143.  
  144.     waitline 
  145.  
  146. // check for various dropped connections
  147.     ifbrk goto endit    
  148.      compa "%lastline%" with "+++"
  149.            ifin goto endit
  150.     compa "%lastline%" with "NO CARRIER"
  151.            ifin goto endit
  152.  
  153.     seta pass "%lastline%"
  154.     lower pass
  155.     rtrim pass
  156.  
  157. // set password to whatever you want
  158.     compa "%pass%" with "password"  
  159.     ifnequ    goto hack        ;// sorry hacker
  160.  
  161. // set initial 'current' directory to whatever you want
  162.     seta curdir "C:\upload."    
  163.  
  164. // MENU
  165. :menu
  166. // load "HOSTAFT" options file, AFTER connect is made
  167.     loadopts "C:\zoc\options\hostaft"
  168.  
  169. // * show menu
  170. // * call subroutine accordingly
  171.     timeout 600
  172.     seta choice " "
  173.     send "^M^J^M^J"
  174.     send "[%curdir%] Your Choice (c/d/ul/dl/b/s/x)?^M^J"
  175.     send "(Change-dir; Dir; UpLoad; DownLoad; Beep host; Shell to os/2; Exit) "
  176.     waitline
  177.     // forget it if WAITLINE timed out or if NO CARRIER occurred
  178.  
  179. // check for various dropped connections
  180.     ifbrk goto endit    
  181.      compa "%lastline%" with "+++"
  182.            ifin goto endit
  183.     compa "%lastline%" with "NO CARRIER"
  184.        ifin goto endit
  185.  
  186. // text cosmetics for user input
  187.     seta choice "%lastline%"
  188.     lower choice
  189.     ltrim choice
  190.     rtrim choice
  191.  
  192. // change directory
  193.     compa "%choice%" with "c"
  194.     ifequ call chdir
  195.  
  196. // show directory
  197.     compa "%choice%" with "d"
  198.     ifequ call showdir
  199.  
  200. // receive file from remote station
  201. // (upload from remote point of view)
  202.     compa "%choice%" with "ul"
  203.     ifequ call upload
  204.  
  205. // send file to remote station
  206. // (download from remote point of view)
  207.     compa "%choice%" with "dl"
  208.     ifequ call download
  209.  
  210. // beep host
  211.     compa "%choice%" with "b"
  212.     ifequ call beepsys
  213.  
  214. // shell to OS/2
  215.     compa "%choice%" with "s"
  216.     ifequ call shell
  217.  
  218. // exit/hangup
  219.     compa "%choice%" with "x"
  220.     ifequ goto endit
  221.  
  222.     goto menu
  223.  
  224. :hack
  225.     send "^M^J^JSorry, no unauthorized personnel...Bye! ^M^J"
  226.     
  227. // ENDIT 
  228. // * hang up line
  229. // * do it all over
  230. :endit
  231. // load "HOSTBEF" options file, to disable SEND ECHO 
  232. //    (would cause infinite loop after disconnect)
  233.         loadopts "C:\zoc\options\hostbef"
  234.     delay 2
  235.     hangup
  236.  
  237.     goto start
  238.  
  239.  
  240. #####################################################################
  241. #   SUBROUTINES                                                     #  
  242. #####################################################################
  243.  
  244. // CHANGE DIRECTORY
  245. // * get input from user and store directory
  246. // * append '.' to root directories (for sake of upload)
  247. :chdir
  248.     send "^M^J^JEnter directory: "
  249.     waitline
  250.  
  251. // check for various dropped connections
  252.     ifbrk goto endit    
  253.      compa "%lastline%" with "+++"
  254.            ifin goto endit
  255.     compa "%lastline%" with "NO CARRIER"
  256.        ifin goto endit
  257.  
  258.     seta curdir "%lastline%"
  259.     seta lastchar "%curdir%" -1 
  260.     compa "%lastchar%" with "\"
  261.     ifequ seta curdir "%curdir%."
  262.     return
  263.  
  264.  
  265. // SHOW DIRECTORY
  266. // * run directory command with output redirection
  267. // * show redirected output via ASCII upload
  268. // * delete redirection file
  269. :showdir
  270.     send "^J"
  271.     shell "dir %curdir% >shellout.tmp"
  272.     upload a "shellout.tmp" 
  273.     shell "del shellout.tmp"
  274.  
  275. // check for various dropped connections
  276.     ifbrk goto endit    
  277.      compa "%lastline%" with "+++"
  278.            ifin goto endit
  279.     compa "%lastline%" with "NO CARRIER"
  280.        ifin goto endit
  281.  
  282.     return
  283.  
  284.  
  285. // RECEIVE FILE FROM REMOTE STATION
  286. // * no USER input required (it's an upload from their point of view)
  287. :upload
  288.     send "^M^J^JPlease start your Zmodem upload or press ^^X "
  289.     send "several times to abort. "
  290.     download z "%curdir%"
  291.  
  292. // check for various dropped connections
  293.     ifbrk goto endit    
  294.      compa "%lastline%" with "+++"
  295.            ifin goto endit
  296.     compa "%lastline%" with "NO CARRIER"
  297.        ifin goto endit
  298.  
  299.     return
  300.  
  301.  
  302. // SEND FILE TO REMOTE STATION
  303. // * get a file name
  304. // * (it's a download from their point of view)
  305. :download
  306.     send "^M^J^JPlease enter the name of the file  "
  307.     send "you want to receive from the ^M^J"
  308.     send "%curdir% directory: "
  309.     wait "^M"
  310.  
  311. // check for various dropped connections
  312.     ifbrk goto endit    
  313.      compa "%lastline%" with "+++"
  314.            ifin goto endit
  315.     compa "%lastline%" with "NO CARRIER"
  316.        ifin goto endit
  317.  
  318.     seta file "%lastline%"
  319.     ltrim file
  320.     rtrim file
  321.     compa "%file%" with ""
  322.     ifequ return
  323.     compa "%file%" with "dl"
  324.     ifequ return
  325.     upload z "%curdir%\\%file%"
  326.  
  327. // check for various dropped connections
  328.     ifbrk goto endit    
  329.      compa "%lastline%" with "+++"
  330.            ifin goto endit
  331.     compa "%lastline%" with "NO CARRIER"
  332.        ifin goto endit
  333.     return
  334.  
  335. // beep host (limited chat)
  336. //
  337. // IF host is available and starts to type, the main menu will continue to appear 
  338. // between his messages (since cannot be sure host is available, have not cut
  339. // into menuing system). When remote caller types, host will be able to view. 
  340. // NOT REAL CHAT MODE, but conversation is possible (amidst reappearing menu).
  341. :beepsys
  342.     send "^M^J^JBeeping host...^M^J"
  343.     BEEP 3
  344.     DELAY 1
  345.     BEEP 2
  346.     DELAY 1
  347.     BEEP 3
  348.     send "(...if there's no answer in half a minute or so, I'm not around...)^M^J"
  349.  
  350. // check for various dropped connections
  351.     ifbrk goto endit    
  352.      compa "%lastline%" with "+++"
  353.            ifin goto endit
  354.     compa "%lastline%" with "NO CARRIER"
  355.        ifin goto endit
  356.  
  357.     return
  358.  
  359. // SHELL TO OS/2 (enter entire OS/2 command including paths)
  360. // (i.e. 'ERASE C:\TEMP\FILE.DOC')
  361. // This is quite powerful, as it allows you to run ANY OS/2 command remotely.
  362. // NO echoing back to remote, though, so the remote user can't see what's happening.
  363. // This allows anyone to remotely do ANYTHING on your system. Use with caution!
  364. :shell
  365.     send "^M^J^JPlease enter the command you want to process:  "
  366.     wait "^M"
  367.  
  368. // check for various dropped connections
  369.     ifbrk goto endit    
  370.      compa "%lastline%" with "+++"
  371.            ifin goto endit
  372.     compa "%lastline%" with "NO CARRIER"
  373.        ifin goto endit  
  374.  
  375.     shell "%lastline%"
  376.  
  377. // check for various dropped connections
  378.     ifbrk goto endit    
  379.      compa "%lastline%" with "+++"
  380.            ifin goto endit
  381.     compa "%lastline%" with "NO CARRIER"
  382.        ifin goto endit  
  383.  
  384.     return
  385. 
  386.