#!/bin/csh # # Determine the Verndor of a device # # csh-Example: # # <1>scsi_vendor # Disks: SEAGATE SAMSUNG # Cdroms: TOSHIBA PHILIPS # Tapes: HP # <2>scsi_vendor disk # SEAGATE SAMSUNG # <383>scsi_vendor cd # TOSHIBA PHILIPS # <3>scsi_vendor tape # HP # <4>scsi_vendor tape 1 # HP # <5>scsi_vendor dsik 1 # <6>scsi_vendor disk 1 # SEAGATE # <7>scsi_vendor disk 2 # SAMSUNG # set s = ( ) ; set c = ( ) ; set d = ( ) ; set x = ( `grep '^ ' /proc/scsi/scsi | cut -c3-18` ) set o = '' ; set v = '' ; foreach i ( $x ) if ( "$o" == 'Vendor:' ) set v = $i ; if ( "$o" == 'Type:' && "$i" == 'Sequenti' ) set s = ( $s $v ); if ( "$o" == 'Type:' && "$i" == 'CD-ROM' ) set c = ( $c $v ); if ( "$o" == 'Type:' && "$i" == 'Direct-A' ) set d = ( $d $v ); set o = $i ; end if ( $# == 0 ) then echo Disks: $d echo Cdroms: $c echo Tapes: $s exit 0 ; endif if ( $# == 1 ) then set v = '' ; if ( $1 == disk ) then echo $d endif if ( $1 == cd ) then echo $c endif if ( $1 == tape ) then echo $s endif exit 0 ; endif if ( $# == 2 ) then set v = '' ; if ( $1 == disk && $#d >= $2 ) then set v = $d[$2] ; endif if ( $1 == cd && $#c >= $2 ) then set v = $c[$2] ; endif if ( $1 == tape && $#s >= $2 ) then set v = $s[$2] ; endif echo $v exit 0 ; endif if ( "$v" == "$3" ) then exit 2 ; endif exit 1 ;