home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 May / PCW596.iso / wtest / clico / sunsoft / pcnfspro / telnet / kertrans.ec_ / kertrans.ECF
Encoding:
Text File  |  1995-10-30  |  9.1 KB  |  255 lines

  1. set nover
  2. !-------------------------------------------------------------------------------
  3. !                       320 KERMIT File Transfer Utility                Rev 1.4
  4. !-------------------------------------------------------------------------------
  5.  
  6. !Modification  History =========================================================
  7. !
  8. ! 02/02/90      B. Johnson      Added SERVER connection for login
  9. ! 04/30/90      B. Johnson      Added NETWORK connection for login
  10. ! 06/22/95      T. Bigelow      Cleanup
  11. !===============================================================================
  12.  
  13. !-------------------------------------------------------------------------------
  14. !                       General KERMIT file transfer utility
  15. !       This EM command file transfers files to or from the HOST using Kermit
  16. !       Server mode. It will login if necessary, start kermit, transfer the
  17. !       file(s) and leave the HOST in the same state as it was found, logged
  18. !       in, at the Command Prompt or in Kermit mode. It can be called
  19. !       from a DOS batch file or from an EM cmd file. Modification of this
  20. !       command file may be necessary to work with HOST systems other then
  21. !       a VAX or with kermit versions other then Kermit32.
  22. !
  23. !           PARAMETERS:
  24. !               [p1] = Username ("ANSWERBACK" uses SEND/ANSWERBACK string)
  25. !               [p2] = Password ("ANSWERBACK" uses SEND/ANSWERBACK string)
  26. !               p3 = 1 if called from EM, 0 if called from DOS
  27. !               p4 = kermit command
  28. !               p5 = File transfer type [(A)scii, (B)inary, (F)ixed]
  29. !                    (Default = Ascii)
  30. !               p6 = Source file name,
  31. !               p7 = Destination file name
  32. !               [p8] = Host node name (Option must include username/password)
  33. !
  34. !           DOS EXAMPLE:
  35. !               DOS batch file VSEND.BAT -
  36. !                       @KERTRANS [USER] [PASSWORD] 0 SEND BINARY %1 %2 [NODE]
  37. !
  38. !               ECL command file KERTRANS.ECF -
  39. !                       @KERTRANS [USER] [PASSWORD] 1 SEND BINARY p1 p2 [NODE]
  40. !-------------------------------------------------------------------------------
  41. !       Note:   A USERNAME and/or PASSWORD of "ANSWERBACK" forces the command
  42. !               SEND/ANSWERBACK to be used to send a consealed username/password
  43. !               or password. Make sure that the ANSWERBACK string ends with a
  44. !               RETURN or the login will fail.
  45. !-------------------------------------------------------------------------------
  46.  
  47. on abort then goto done
  48. set abort
  49.  
  50. !       If no username or password, reset p3 - p8
  51.  
  52. if (p1 .nes. "0") .and. (p1 .nes. "1") then goto check_p
  53. p8 = p6
  54. p7 = p5
  55. p6 = p4
  56. p5 = p3
  57. p4 = p2
  58. p3 = p1
  59. p2 = ""
  60. p1 = ""
  61.  
  62. !       If no password, reset p3 - p8
  63.  
  64. check_p:
  65. if (p2 .nes. "0") .and. (p2 .nes. "1") then goto set_type
  66. p8 = p7
  67. p7 = p6
  68. p6 = p5
  69. p5 = p4
  70. p4 = p3
  71. p3 = p2
  72. p2 = ""
  73. !       Get file transfer type
  74.  
  75. set_type:
  76. ftype = "ASCII"
  77. if f$ext(0,1,"''p5'") .eqs. "B" then ftype = "BINARY"
  78. if f$ext(0,1,"''p5'") .eqs. "F" then ftype = "FIXED"
  79.  
  80. !*******************************************************************************
  81. !*                      *** PROMPT VARIABLES ***
  82. !* The following symbols may need changing for different host systems *
  83. host_prompt = "<null>"                          !* Host prompt *
  84. server_prompt = "local> "                       !* Server prompt *
  85. server_connect = "c"                            !* Server connect command *
  86. user_prompt = "Username:"                       !* User prompt *
  87. password_prompt = "Password:"                   !* Passwod prompt *
  88. kermit_prompt = "32"                            !* Kermit prompt *
  89. logout_cmd = "logout"                           !* Logout command *
  90. exit_cmd = "exit"                               !* Exit kermit or other cmd *
  91. abort_signal = ""                            !* Xoff, Abort or break signal *
  92. !*******************************************************************************
  93.  
  94. !*              * set kermit file type command *
  95. set_file_type_cmd = "write host ""set file type ''ftype'"""
  96.  
  97. p3 = p3                                         !set p3 numeric
  98. login_fl = 0
  99. ker_label := ker_exit
  100.  
  101. if "''p6'" .eqs."" then goto nofile
  102.  
  103. on warning then goto error
  104. set on
  105. display "EM-I-TRANSETUP, File transfer SETUP in progress"
  106.  
  107. !       Synchronize to HOST command input mode
  108.  
  109. set noon                                        !suppress timeout error msg
  110. wait /nodisp /nomessage /time=1                 !flush for 1 seconds
  111. set on
  112.  
  113. !-------------------------------------------------------------------------------
  114. !                       Check for login
  115. !-------------------------------------------------------------------------------
  116.  
  117. login:
  118. if p1 .eqs. "" then goto nologin_prompt         !check for username/password
  119. if p8 .eqs. "" then goto login1                 !check for network connect
  120. set noon
  121. set host 'p8'                                   !connect to network
  122. set on
  123. login1:
  124. write host                                      !send return for login prompt
  125. set noon                                        !suppress timeout error msg
  126. wait /error=nouser /nodisp /nomessage /time=3 user_prompt
  127. goto gotprompt
  128. nouser:
  129. write host abort_signal                         !send abort or break
  130. write host                                      !send return for login prompt
  131. wait /error=server_prompt /nodisp /nomessage /time=3 user_prompt
  132. goto gotprompt
  133. server_prompt:
  134. write host                                      !send return for server prompt
  135. wait /error=nologin_prompt/nodisp /nomessage /time=3 server_prompt
  136. write host server_connect
  137. write host                                      !send return for login prompt
  138. wait /error=nologin_prompt /nodisp /nomessage /time=3 user_prompt
  139. gotprompt:
  140. set noabort
  141. if p1 .eqs. "ANSWERBACK" then goto send_answerback
  142. write host "''p1'"                              !send username
  143. wait /error=nologin /nodisp /nomessage /time=3 password_prompt
  144. set on
  145. if p2 .nes. "ANSWERBACK" then goto send_pass
  146. send_answerback:
  147. send /answerback                                !send ANSWERBACK string
  148. goto wait_prompt
  149. send_pass:
  150. write host "''p2'"
  151.  
  152. wait_prompt:
  153. set noon                                        !suppress timeout error msg
  154. write host                                      !send return for login prompt
  155. !               wait for host prompt
  156. wait /error=noprompt /nodisp /nomessage /time=10 host_prompt
  157. set on
  158. login_fl = 1
  159. goto kermit
  160.  
  161. nologin_prompt:
  162. set noon                                        !suppress timeout error msg
  163. write host                                      !send return for login prompt
  164. !               Wait for host prompt
  165. wait /error=noprompt /nodisp /nomessage /time=10 host_prompt
  166. set on
  167.  
  168. !-------------------------------------------------------------------------------
  169. !               KERMIT file transfer routine
  170. !-------------------------------------------------------------------------------
  171.  
  172. kermit:
  173. set nover
  174. on abort then goto error
  175. on warning then continue
  176. on error then goto error
  177. set abort
  178. set on
  179. write host "kermit"
  180. set noon                                        !suppress timeout error msg
  181. !               Wait for kermit prompt
  182. wait /error='ker_label' /nodisp /nomessage /time_out=5 kermit_prompt
  183. set on
  184. !*              * Set file type *
  185. set_file_type_cmd
  186. write host "server"
  187. set noon                                        !suppress timeout error msg
  188. wait /nodisp /nomessage /time=1                 !flush for 1 seconds
  189. set on
  190. kermit 'p4' 'p6' 'p7'
  191. if $statusid .eqs. "FILEOPEN" then delay/nodisp/nomess 3
  192. on warning then goto error
  193. kermit end
  194.  
  195. !       Exit routines
  196.  
  197. done:
  198. status_code = $status
  199.  
  200. exit:
  201. set noabort
  202. on error then goto exit_out
  203. write host exit_cmd                             !exit if in kermit or other cmd
  204. if login_fl then write host logout_cmd          !logout
  205. set noon                                        !suppress timeout error msg
  206. wait /nodisp /nomessage /time=1                 !flush for 1 seconds
  207.  
  208. exit_out:
  209. if p3 then exit status_code
  210. exit/em status_code
  211.  
  212. !-------------------------------------------------------------------------------
  213. !                       Exit and error handler
  214. !-------------------------------------------------------------------------------
  215.  
  216. error:
  217. on warning then goto error
  218. status_code = $status
  219. display "EM-I-TRANERROR, File transfer ERROR, exiting routine"
  220. on abort then goto abort_out
  221. delay/nodisp/nomess 3
  222. set abort
  223. kermit end
  224. goto exit
  225.  
  226. abort_out:
  227. write/nocr host abort_signal                    !abort what ever
  228. goto exit
  229.  
  230. ker_exit:
  231. ker_label:=ker_cont_y
  232. write host exit_cmd                             !exit if in kermit or other cmd
  233. goto kermit
  234.  
  235. ker_cont_y:
  236. ker_label:=error
  237. kermit end
  238. goto kermit
  239.  
  240. nologin:
  241. display "EM-W-BADLOGIN, Improper LOGIN response - check connection and try again"
  242. goto noprompt1
  243. noprompt:
  244. display "EM-W-NORESPONSE, Improper HOST prompt response - check program prompt variables"
  245. noprompt1:
  246. delay/nodisp/nomess 3
  247. if p3 then exit
  248. exit/em
  249.  
  250. nofile:
  251. display "EM-W-NOFILENAM, File name not specified"
  252. delay/nodisp/nomess 3
  253. if p3 then exit
  254. exit/em
  255.