File: scsi_vendor

package info (click to toggle)
dds2tar 2.5.2-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 528 kB
  • sloc: ansic: 2,889; makefile: 593; sh: 213; csh: 50
file content (75 lines) | stat: -rwxr-xr-x 1,321 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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 ;