1#!/bin/bash 2 3################################################ 4# 5# Send a TEST UNIT READY SCSI command to each given device. 6# 7# This script assumes the sg3_utils package is installed and uses 8# the sg_turs utility.. 9# 10############################################### 11 12verbose="" 13brief="" 14 15usage() 16{ 17 echo "Usage: scsi_ready [-b] [-h] [-v] <device>+" 18 echo " where:" 19 echo " -b, --brief print 'ready' or 'device not ready' only" 20 echo " -h, --help print usage message" 21 echo " -v, --verbose more verbose output" 22 echo "" 23 echo "Send SCSI TEST UNIT READY to each <device>" 24} 25 26opt="$1" 27while test ! -z "$opt" -a -z "${opt##-*}"; do 28 opt=${opt#-} 29 case "$opt" in 30 b|-brief) brief="1" ;; 31 h|-help) usage ; exit 0 ;; 32 v|-verbose) verbose="-v" ;; 33 vv) verbose="-vv" ;; 34 vvv) verbose="-vvv" ;; 35 *) echo "Unknown option: -$opt " ; exit 1 ;; 36 esac 37 shift 38 opt="$1" 39done 40 41if [ $# -lt 1 ] 42 then 43 usage 44 exit 1 45fi 46 47for i 48do 49 if [ ! $brief ] ; then 50 echo "sg_turs $verbose $i" 51 fi 52 echo -n " " 53 if sg_turs $verbose $i ; then 54 echo "ready" 55 fi 56done 57