home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / OS2 / ZOC121.ZIP / ZOC / SCRIPT / MINIHOST < prev    next >
Text File  |  1994-02-13  |  5KB  |  161 lines

  1. #######################################################################
  2. #                                                                     #
  3. #   This script is a small host (like the one in ProComm(TM))         #
  4. #                                                                     #
  5. #   It's not fairly well tested but maybe someone is in the mood      #
  6. #   to play around with it a bit more and make the result available   #
  7. #   on the internet or packaged with ZOC                              #
  8. #                                                                     #
  9. #   It takes incoming calls and lets the user change directory,       #
  10. #   show directories and send/receive files.                          #
  11. #                                                                     #
  12. #   Possible extensions:                                              #
  13. #    * TYPE command to show ASCII files                               #
  14. #    * options for DIR (like /o or /a)                                #
  15. #    * other non-interactive shell commands (like DEL)                #
  16. #    * page system owner for a chat                                   #
  17. #    * more sophisticated timeout control for dropped connections     #
  18. #                                                                     #
  19. #######################################################################
  20.  
  21. // This SCRIPT requires the following options to be set
  22. // * Host Echo On (Options, Terminal)
  23. // * Ascii Delay 0 (Options, Transfer)
  24.  
  25.  
  26. // Set script to exact mode and modem to 
  27. // auto answer
  28. exact 1
  29. send "ATS0=1"
  30.  
  31. // ENTRY 
  32. // * wait for connect and set serial speed
  33. // * ask for password
  34. // * hangup if pw wrong
  35. :allover
  36.     wait CONNECT        ;// wait for connect
  37.  
  38.     wait "^M"              ;// the stuff after connect is the speed
  39.     baud "%lastline%"
  40.  
  41.     // show welcome screen
  42.     send "^[[2J"
  43.     send "Welcome!^M^J^M^J"
  44.     send "Enter Password :"
  45.     timeout 60
  46.     waitline 
  47.     seta pass "%lastline%"
  48.     lower pass
  49.     rtrim pass
  50.     compa "%pass%" with "secret"
  51.     ifnequ    goto endit        ;// sorry hacker
  52.  
  53.     seta curdir "C:\."
  54.  
  55. // MENU
  56. // * show menu
  57. // * call subroutine accordingly
  58. :menu
  59.     timeout 300
  60.     seta choice " "
  61.     send "^M^J^M^J"
  62.     send "[%curdir%] Your Choice (cd/dir/zu/zd/exit) ? "
  63.     waitline
  64.  
  65.     // forget it if WAITLINE timed out or if NO CARRIER occured
  66.     ifbrk goto endit    
  67.     compa "%lastline%" with "NO CARRIER"
  68.     ifin goto endit
  69.  
  70.     // text cosmetics for user input
  71.     seta choice "%lastline%"
  72.     lower choice
  73.     ltrim choice
  74.     rtrim choice
  75.  
  76.     // change directory
  77.     compa "%choice%" with "cd"
  78.     ifequ call chdir
  79.  
  80.     // show directory
  81.     compa "%choice%" with "dir"
  82.     ifequ call showdir
  83.  
  84.     // receive file from remote station
  85.     // (upload from remote point of view)
  86.     compa "%choice%" with "zu"
  87.     ifequ call upload
  88.  
  89.     // send file to remote station
  90.     // (download from remote point of view)
  91.     compa "%choice%" with "zd"
  92.     ifequ call download
  93.  
  94.     // exit/hangup
  95.     compa "%choice%" with "exit"
  96.     ifequ goto endit
  97.  
  98.     goto menu
  99.  
  100. // ENDIT 
  101. // * hang up line
  102. // * do it all over
  103. :endit
  104.     hangup
  105.     goto allover
  106.  
  107.  
  108.  
  109.  
  110. #####################################################################
  111. #   SUBROUTINES                                                     #  
  112. #####################################################################
  113.  
  114. // CHANGE DIRECTORY
  115. // * get input from user and store directory
  116. // * append '.' to root directories (for sake of upload)
  117. :chdir
  118.     send "^M^JEnter directory: "
  119.     waitline
  120.     seta curdir "%lastline%"
  121.     seta lastchar "%curdir%" -1 
  122.     compa "%lastchar%" with "\"
  123.     ifequ seta curdir "%curdir%."
  124.     return
  125.  
  126.  
  127. // SHOW DIRECTORY
  128. // * run directory command with output redirection
  129. // * show redirected output via ASCII upload
  130. // * delete redirection file
  131. :showdir
  132.     shell "dir %curdir% >shellout.tmp"
  133.     upload a "shellout.tmp" 
  134.     shell "del shellout.tmp"
  135.     return
  136.  
  137.  
  138. // RECEIVE FILE FROM REMOTE STATION
  139. // * no USER input required (it's an upload from their point of view)
  140. :upload
  141.     send "^M^JPlease start your Zmodem upload or press ^^X "
  142.     send "several times to abort. "
  143.     download z "%curdir%"
  144.     return
  145.  
  146.  
  147. // SEND FILE TO REMOTE STATION
  148. // * get a file name
  149. // * (it's a download from their point of view)
  150. :download
  151.     send "^M^JPlease enter the name of the file  "
  152.     send "you want to receive from the ^M^J"
  153.     send "%curdir% directory: "
  154.     wait "^M"
  155.     seta file "%lastline%"
  156.     ltrim file
  157.     rtrim file
  158.     compa "%file%" with ""
  159.     ifnequ upload z "%curdir%\\%file%"
  160.     return
  161.