home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 February / psl_9403.zip / psl_9403 / DOS / COMMUNIC / HA221B.ZIP / SAMPDOWN.SCR < prev    next >
Text File  |  1993-07-27  |  2KB  |  101 lines

  1. REM SAMPDOWN.SCR
  2. REM 07/27/93
  3. REM Sample script to log-on to Unix and download a file
  4. REM
  5. DIM file 64
  6. REM
  7. REM logname:  the login name of the user
  8. REM password: the login password of the user
  9. REM file:     the name of the file to download
  10. REM
  11. LET logname = username
  12. LET password = userpass
  13. LET file = /usr/data/datafile
  14. REM
  15. REM First, tell the user what we're going to do
  16. REM
  17. SCREEN ON
  18. CLS
  19. ECHO Logging on to the Unix system...
  20. SCREEN OFF
  21. REM
  22. REM See if Unix is there -- look for login:
  23. REM
  24. TIMEOUT 2
  25. SEND {CR}
  26. EXPECT ogin:
  27. IF {err} = 0 GOTO LOGIN
  28. REM
  29. REM Send a Ctrl-D in case we're already logged in
  30. REM
  31. :AGAIN
  32. SEND {04}
  33. EXPECT ogin:
  34. IF {err} <> 0 GOTO NOUNIX
  35. :LOGIN
  36. REM
  37. REM Now attempt to log in -- send user name
  38. REM
  39. WAIT 1
  40. SEND {logname}{CR}
  41. REM
  42. REM Now send password (give Unix 4 seconds to respond)
  43. REM
  44. TIMEOUT 4
  45. EXPECT word:
  46. IF {err} <> 0 GOTO AGAIN
  47. SEND {password}{CR}
  48. EXPECT $
  49. IF {err} <> 0 GOTO NOUNIX
  50. REM
  51. REM Now check to see if the file exists
  52. REM
  53. SCREEN ON
  54. CLS
  55. ECHO Checking for file {file}...
  56. SCREEN OFF
  57. TIMEOUT 2
  58. SEND [ -r "{file}" ] ; echo $?{CR}
  59. EXPECT {LF}
  60. READ res
  61. IF {res} <> 0 GOTO NOFILE
  62. SCREEN ON 
  63. CLS
  64. ECHO Downloading the file {file}...
  65. SCREEN OFF
  66. TIMEOUT 4
  67. SEND /usr/bin/hsend {file}{CR}
  68. EXPECT {LF}
  69. EXPECT $
  70. TIMEOUT 2
  71. SEND echo $?{CR}
  72. EXPECT {LF}
  73. READ res
  74. IF {res} <> 0 GOTO BADXFER
  75. SCREEN ON
  76. CLS
  77. ECHO The file {file} was successfully downloaded.
  78. SCREEN OFF
  79. STOP
  80. :NOUNIX
  81. SCREEN ON
  82. CLS
  83. ECHO Cannot log on to Unix.
  84. ECHO Contact the system administrator.
  85. ECHO
  86. STOP
  87. :NOFILE
  88. SCREEN ON
  89. CLS
  90. ECHO The file {file} does not exist on the Unix system.
  91. SCREEN OFF
  92. STOP
  93. :BADXFER
  94. SCREEN ON
  95. CLS
  96. ECHO An error occurred during the transfer 
  97. ECHO of the file {file}.
  98. ECHO Please try again.
  99. SCREEN OFF
  100. STOP
  101.