home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / acp / root.9 / usr / bin / tape / tape
Encoding:
Text File  |  1998-08-19  |  3.5 KB  |  139 lines

  1. #!/sbin/sh
  2.  
  3. # Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  4. #                                                                         
  5. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  6. #                   SANTA CRUZ OPERATION INC.                             
  7. #                                                                         
  8. #   The copyright notice above does not evidence any actual or intended   
  9. #   publication of such source code.                                      
  10.  
  11. #ident    "@(#)sco:tape.sh    1.1.1.5"
  12. #
  13. # Enhanced Application Compatibility Support
  14. # This shell script is intended to behave like SCO's tape command.
  15. # The tape command is implemented as an interface to USL's tapecntl command.
  16. # The following SCO's tape command options are not supported.
  17. #        status    - get the status of the tape 
  18. #        amount    - amount of current or last transfer 
  19. #        wfm    - write filemark 
  20. # Also, options and arguments related to the QIC-40 and QIC-80 minitapes
  21. # are not supported.
  22. # Since one driver now supports both SCSI and non-SCSI devices, the -s and
  23. # -c options are not necessary.  However, they will continue to be supported
  24. # for compatibility.
  25. #
  26. # Name: tape
  27. # Usage:
  28. #    tape usage: tape [-<type>] <command> [device]
  29. #      type: c (non-SCSI) or s (SCSI)
  30. #      Cartridge tape commands:
  31. #        reten    - retension the tape
  32. #        erase    - erase and retension tape
  33. #        reset    - reset controller and drive
  34. #        rewind    - rewind tape controller
  35. #        rfm    - skip to next file
  36. #
  37. # exit codes
  38. #    1: Special device files /dev/rmt/ctape1 and ctape2 don't exist
  39. #    2: Specified device does not exist
  40. #    3: Illegal options/arguments
  41.  
  42. TAPECNTL="/usr/bin/tapecntl"
  43. DFLT_DEVICE=""
  44. command=""
  45. USAGE="\ntape usage: tape [-<type>] <command> [device]\n\
  46.       type: c (non-SCSI) or s (SCSI)\n\
  47.       Cartridge tape commands:\n\
  48.     \treten\t- retension the tape\n\
  49.     \terase\t- erase and retension tape\n\
  50.     \treset\t- reset controller and drive\n\
  51.     \trewind\t- rewind tape controller\n\
  52.     \trfm\t- skip to next file\n"
  53.  
  54. # Check if the default tape file exists
  55. if [ -f /etc/default/tape ]
  56. then
  57.     DFLT_DEVICE=`grep device /etc/default/tape | cut -f2 -d "="` 
  58. fi
  59.  
  60. # Check if tape device on system
  61. if [ -c /dev/rmt/ctape1 ]
  62. then
  63.     TAPEDEVICE=/dev/rmt/ctape1
  64. elif [ -c /dev/rmt/ctape2 ]
  65. then
  66.     TAPEDEVICE=/dev/rmt/ctape2
  67. else
  68.     echo "$0: ERROR: /dev/rmt/ctape1 or /dev/rmt/ctape2: No such files"
  69.     exit 1
  70. fi
  71.  
  72. ####
  73. ## Note: the -c and -s options are maintained for backward compatibility,
  74. ##       and are no longer needed since the advent of PDI. With PDI both
  75. ##       SCSI and Non-SCSI tapes are handled in a common manner via
  76. ##       the st01(7) target driver.
  77. ####
  78. while getopts cs OPTION
  79. do
  80.     case ${OPTION} in
  81.     c)
  82.         ;;
  83.     s)
  84.         ;;
  85.     \?)
  86.         echo ${USAGE}
  87.         exit 3
  88.     esac
  89. done
  90.  
  91. shift `expr ${OPTIND} - 1`
  92.  
  93. command="${1}"
  94.  
  95. if [ "x${2}" = "x" ]
  96. then
  97.     if [ "${DFLT_DEVICE}" ]
  98.     then
  99.         TAPEDEVICE=${DFLT_DEVICE}
  100.     fi
  101. else
  102.     if [ -c ${2} ]
  103.     then
  104.         TAPEDEVICE=${2}
  105.     elif [ -c /dev/rmt/${2} ]
  106.     then
  107.         TAPEDEVICE="/dev/rmt/${2}"
  108.     else
  109.         echo "Invalid device: ${2}"
  110.         echo ${USAGE}
  111.         exit 3
  112.     fi
  113. fi
  114.  
  115. case ${command} in 
  116.     reten)
  117.         $TAPECNTL -t $TAPEDEVICE
  118.         ;;
  119.     erase)
  120.         $TAPECNTL -e $TAPEDEVICE
  121.         ;;
  122.     reset)
  123.         $TAPECNTL -r $TAPEDEVICE
  124.         ;;
  125.     rewind)
  126.         $TAPECNTL -w $TAPEDEVICE
  127.         ;;
  128.     rfm)
  129. # need to strip off first character (c) and replace it with n - ctape1 -> ntape1
  130.         $TAPECNTL -p 1 `echo ${TAPEDEVICE} | sed 's/ctape/ntape/'`
  131.         ;;
  132.     *)
  133.         echo "Invalid command: ${command}"
  134.         echo ${USAGE}
  135.         exit 3
  136.         ;;
  137. esac
  138. # End Enhanced Application Compatibility Support
  139.