3 # show generic devices for CDROM SCSI devices
5 # needs a mounted /proc filesystem, printf, echo and grep
7 # when invoked with a number, the n-th cdrom SCSI address is
10 # example: 'scan_scsi.linux 2' will print the SCSI settings for
11 # the second cdrom device, namely '0,4,0' in my
14 # BUGS: limited to 9 devices
20 if [ ".${ID%%' '}" = ".Attached devices:" ]; then
24 read ignore type ignore;
25 echo $ID ' ' $type ' -> ' /dev/sg$NUMBER
26 #echo $ID ' ' $type ' -> ' /dev/sg$NUMBER or /dev/sg$LETTER
27 NUMBER=$(($NUMBER + 1))
28 #done <test_scanscsi | grep "WORM\|CD-ROM" |
29 done </proc/scsi/scsi | grep "WORM\|CD-ROM" | \
31 while read CD_DRIVE; do
32 if test $# -ne 0; then
33 if test $DRIVES -eq $1; then
34 CD_DRIVE=${CD_DRIVE#Host: scsi}
35 SCSIHOST=${CD_DRIVE%% *}
36 CHANNEL=${CD_DRIVE#*Channel: }
37 CHANNEL=${CHANNEL%% *}
38 SCSIID=${CD_DRIVE#*Id: }
40 SCSILUN=${CD_DRIVE#*Lun: }
41 SCSILUN=${SCSILUN%% *}
42 #CD_DRIVE=${CD_DRIVE% or /dev/*}
43 echo ${CHANNEL},${SCSIID},${SCSILUN}
49 DRIVES=$(($DRIVES + 1))