home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1987 / 06 / bbs.l2 < prev    next >
Text File  |  1987-05-05  |  2KB  |  85 lines

  1. Listing Two
  2.  
  3. dwnld
  4.  
  5.  
  6.  
  7.     # identify which file directory (contained in the first argument - $1)
  8.  
  9. 1    if [ "$1" = MS ]
  10. 2    then
  11.  
  12.     # an MS-DOS file
  13.  
  14. 3        filedir=/u/bbs/MS-files
  15. 4    elif [ "$1" = Mac ]
  16. 5    then
  17.  
  18.     # a Macintosh file
  19.  
  20. 6        filedir=/u/bbs/Mac-files
  21. 7    elif [ "$1" = Unix ]
  22. 8    then
  23.  
  24.     # a Unix file
  25.  
  26. 9        filedir=/u/bbs/Unix-files
  27. 10    else
  28.  
  29.     # no valid file directory was entered
  30.  
  31. 11        echo "Follow the dwnld command with a file directory - MS, Mac, or Unix"
  32. 12    fi
  33.  
  34.     # verify that a file name has been entered (contained in the second argument - $2)
  35.  
  36. 13    if [ -n "$2" ]
  37. 14    then
  38.  
  39.     # verify that the file name exists within the selected directory
  40.  
  41. 15        if [ -f "$filedir/$2" ]
  42. 16        then
  43. 17            echo 'who am i | cut -f1 -d" " ' 'date | cut -c1-16 ' "dwnld" $1 $2 >>/u/bbs/log.file
  44.  
  45.     # select a file transfer protocol
  46.  
  47. 18            echo "Transfer potocol (X = Xmodem; A = ASCII): \c"
  48. 19            read method
  49. 20            if [ "$method" = X -o "$method" = x ]
  50. 21            then
  51.  
  52.     # send a binary file using the XModem protocol
  53.  
  54. 22                xmodem -sb $filedir/$2
  55. 23            else
  56.  
  57.     # send an ASCII file
  58. 24                echo "Prepare to transfer file.  Press return to start."
  59. 25                read dummy
  60. 26                cat $filedir/$2
  61. 27                sleep 5
  62. 28                echo "Download complete.  Press return to continue."
  63. 29                read dummy
  64. 30            fi
  65. 31        else
  66.  
  67.     # a valid file name wasn't entered
  68.  
  69. 32            echo "Sorry, that file name does not exist.  Be sure to type the"
  70. 33            echo "file name exactly as it appears in the directory listing."
  71. 34            echo "Upper and lower case letters are different."
  72. 35        fi
  73. 36    else
  74.  
  75.     # no file name was entered
  76.  
  77. 37        echo "Please enter a file name after the directory on the command line."
  78. 38        echo "Use the list command to see available file names."
  79. 39    fi
  80.  
  81.  
  82.  
  83.  
  84.  
  85.