home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1994 February
/
psl_9403.zip
/
psl_9403
/
DOS
/
COMMUNIC
/
HA221B.ZIP
/
SAMPDOWN.SCR
< prev
next >
Wrap
Text File
|
1993-07-27
|
2KB
|
101 lines
REM SAMPDOWN.SCR
REM 07/27/93
REM Sample script to log-on to Unix and download a file
REM
DIM file 64
REM
REM logname: the login name of the user
REM password: the login password of the user
REM file: the name of the file to download
REM
LET logname = username
LET password = userpass
LET file = /usr/data/datafile
REM
REM First, tell the user what we're going to do
REM
SCREEN ON
CLS
ECHO Logging on to the Unix system...
SCREEN OFF
REM
REM See if Unix is there -- look for login:
REM
TIMEOUT 2
SEND {CR}
EXPECT ogin:
IF {err} = 0 GOTO LOGIN
REM
REM Send a Ctrl-D in case we're already logged in
REM
:AGAIN
SEND {04}
EXPECT ogin:
IF {err} <> 0 GOTO NOUNIX
:LOGIN
REM
REM Now attempt to log in -- send user name
REM
WAIT 1
SEND {logname}{CR}
REM
REM Now send password (give Unix 4 seconds to respond)
REM
TIMEOUT 4
EXPECT word:
IF {err} <> 0 GOTO AGAIN
SEND {password}{CR}
EXPECT $
IF {err} <> 0 GOTO NOUNIX
REM
REM Now check to see if the file exists
REM
SCREEN ON
CLS
ECHO Checking for file {file}...
SCREEN OFF
TIMEOUT 2
SEND [ -r "{file}" ] ; echo $?{CR}
EXPECT {LF}
READ res
IF {res} <> 0 GOTO NOFILE
SCREEN ON
CLS
ECHO Downloading the file {file}...
SCREEN OFF
TIMEOUT 4
SEND /usr/bin/hsend {file}{CR}
EXPECT {LF}
EXPECT $
TIMEOUT 2
SEND echo $?{CR}
EXPECT {LF}
READ res
IF {res} <> 0 GOTO BADXFER
SCREEN ON
CLS
ECHO The file {file} was successfully downloaded.
SCREEN OFF
STOP
:NOUNIX
SCREEN ON
CLS
ECHO Cannot log on to Unix.
ECHO Contact the system administrator.
ECHO
STOP
:NOFILE
SCREEN ON
CLS
ECHO The file {file} does not exist on the Unix system.
SCREEN OFF
STOP
:BADXFER
SCREEN ON
CLS
ECHO An error occurred during the transfer
ECHO of the file {file}.
ECHO Please try again.
SCREEN OFF
STOP