home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 May
/
PCW596.iso
/
wtest
/
clico
/
sunsoft
/
pcnfs51
/
pcnfs51.lzh
/
TELNETW.ZOO
/
kertrans.ecf
< prev
next >
Wrap
Text File
|
1994-08-27
|
8KB
|
246 lines
set nover
!-------------------------------------------------------------------------------
! TELNET/TELNETW KERMIT File Transfer Utility
!-------------------------------------------------------------------------------
!
!-------------------------------------------------------------------------------
! General KERMIT file transfer utility
! This EM command file transfers files to or from the HOST using Kermit
! Server mode. It will login if necessary, start kermit, transfer the
! file(s) and leave the HOST in the same state as it was found, logged
! in, at the Command Prompt or in Kermit mode. It can be called
! from a DOS batch file or from an EM cmd file. Modification of this
! command file may be necessary to work with HOST systems other then
! a VAX or with kermit versions other then Kermit32.
!
! PARAMETERS:
! [p1] = Username ("ANSWERBACK" uses SEND/ANSWERBACK string)
! [p2] = Password ("ANSWERBACK" uses SEND/ANSWERBACK string)
! p3 = 1 if called from EM, 0 if called from DOS
! p4 = kermit command
! p5 = File transfer type [(A)scii, (B)inary, (F)ixed]
! (Default = Ascii)
! p6 = Source file name,
! p7 = Destination file name
! [p8] = Host node name (Option must include username/password)
! DOS EXAMPLE:
! DOS batch file VSEND.BAT -
! @KERBIN [USER] [PASSWORD] 0 SEND BINARY %1 %2 [NODE]
! ECL command file ESEND.ECF -
! @KERBIN [USER] [PASSWORD] 1 SEND BINARY p1 p2 [NODE]
!-------------------------------------------------------------------------------
! Note: A USERNAME and/or PASSWORD of "ANSWERBACK" forces the command
! SEND/ANSWERBACK to be used to send a consealed username/password
! or password. Make sure that the ANSWERBACK string ends with a
! RETURN or the login will fail.
!-------------------------------------------------------------------------------
on abort then goto done
set abort
! If no username or password, reset p3 - p8
if (p1 .nes. "0") .and. (p1 .nes. "1") then goto check_p
p8 = p6
p7 = p5
p6 = p4
p5 = p3
p4 = p2
p3 = p1
p2 = ""
p1 = ""
! If no password, reset p3 - p8
check_p:
if (p2 .nes. "0") .and. (p2 .nes. "1") then goto set_type
p8 = p7
p7 = p6
p6 = p5
p5 = p4
p4 = p3
p3 = p2
p2 = ""
! Get file transfer type
set_type:
ftype = "ASCII"
if f$ext(0,1,"''p5'") .eqs. "B" then ftype = "BINARY"
if f$ext(0,1,"''p5'") .eqs. "F" then ftype = "FIXED"
!*******************************************************************************
!* *** PROMPT VARIABLES ***
!* The following symbols may need changing for different host systems *
host_prompt = "<null>" !* Host prompt *
server_prompt = "local> " !* Server prompt *
server_connect = "c" !* Server connect command *
user_prompt = "Username:" !* User prompt *
password_prompt = "Password:" !* Passwod prompt *
kermit_prompt = "32" !* Kermit prompt *
logout_cmd = "logout" !* Logout command *
exit_cmd = "exit" !* Exit kermit or other cmd *
abort_signal = "" !* Xoff, Abort or break signal *
!*******************************************************************************
!* * set kermit file type command *
set_file_type_cmd = "write host ""set file type ''ftype'"""
p3 = p3 !set p3 numeric
login_fl = 0
ker_label := ker_exit
if "''p6'" .eqs."" then goto nofile
on warning then goto error
set on
display "EM-I-TRANSETUP, File transfer SETUP in progress"
! Synchronize to HOST command input mode
set noon !suppress timeout error msg
wait /nodisp /nomessage /time=1 !flush for 1 seconds
set on
!-------------------------------------------------------------------------------
! Check for login
!-------------------------------------------------------------------------------
login:
if p1 .eqs. "" then goto nologin_prompt !check for username/password
if p8 .eqs. "" then goto login1 !check for network connect
set noon
set host 'p8' !connect to network
set on
login1:
write host !send return for login prompt
set noon !suppress timeout error msg
wait /error=nouser /nodisp /nomessage /time=3 user_prompt
goto gotprompt
nouser:
write host abort_signal !send abort or break
write host !send return for login prompt
wait /error=server_prompt /nodisp /nomessage /time=3 user_prompt
goto gotprompt
server_prompt:
write host !send return for server prompt
wait /error=nologin_prompt/nodisp /nomessage /time=3 server_prompt
write host server_connect
write host !send return for login prompt
wait /error=nologin_prompt /nodisp /nomessage /time=3 user_prompt
gotprompt:
set noabort
if p1 .eqs. "ANSWERBACK" then goto send_answerback
write host "''p1'" !send username
wait /error=nologin /nodisp /nomessage /time=3 password_prompt
set on
if p2 .nes. "ANSWERBACK" then goto send_pass
send_answerback:
send /answerback !send ANSWERBACK string
goto wait_prompt
send_pass:
write host "''p2'"
wait_prompt:
set noon !suppress timeout error msg
write host !send return for login prompt
! wait for host prompt
wait /error=noprompt /nodisp /nomessage /time=10 host_prompt
set on
login_fl = 1
goto kermit
nologin_prompt:
set noon !suppress timeout error msg
write host !send return for login prompt
! Wait for host prompt
wait /error=noprompt /nodisp /nomessage /time=10 host_prompt
set on
!-------------------------------------------------------------------------------
! KERMIT file transfer routine
!-------------------------------------------------------------------------------
kermit:
set nover
on abort then goto error
on warning then continue
on error then goto error
set abort
set on
write host "kermit"
set noon !suppress timeout error msg
! Wait for kermit prompt
wait /error='ker_label' /nodisp /nomessage /time_out=5 kermit_prompt
set on
!* * Set file type *
set_file_type_cmd
write host "server"
set noon !suppress timeout error msg
wait /nodisp /nomessage /time=1 !flush for 1 seconds
set on
kermit 'p4' 'p6' 'p7'
if $statusid .eqs. "FILEOPEN" then delay/nodisp/nomess 3
on warning then goto error
kermit end
! Exit routines
done:
status_code = $status
exit:
set noabort
on error then goto exit_out
write host exit_cmd !exit if in kermit or other cmd
if login_fl then write host logout_cmd !logout
set noon !suppress timeout error msg
wait /nodisp /nomessage /time=1 !flush for 1 seconds
exit_out:
if p3 then exit status_code
exit/em status_code
!-------------------------------------------------------------------------------
! Exit and error handler
!-------------------------------------------------------------------------------
error:
on warning then goto error
status_code = $status
display "EM-I-TRANERROR, File transfer ERROR, exiting routine"
on abort then goto abort_out
delay/nodisp/nomess 3
set abort
kermit end
goto exit
abort_out:
write/nocr host abort_signal !abort what ever
goto exit
ker_exit:
ker_label:=ker_cont_y
write host exit_cmd !exit if in kermit or other cmd
goto kermit
ker_cont_y:
ker_label:=error
kermit end
goto kermit
nologin:
display "EM-W-BADLOGIN, Improper LOGIN response - check connection and try again"
goto noprompt1
noprompt:
display "EM-W-NORESPONSE, Improper HOST prompt response - check program prompt variables"
noprompt1:
delay/nodisp/nomess 3
if p3 then exit
exit/em
nofile:
display "EM-W-NOFILENAM, File name not specified"
delay/nodisp/nomess 3
if p3 then exit
exit/em