Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- foo()
- {
- while read line; do
- # debugging
- echo " read line:$line"
- # look for the line describing the assigned system device
- ihas=`echo "$line" | grep 'Attached scsi disk' | awk '{print $4};'`
- # a 'non-zero' variable for $ihas means it's captured the disk device
- # assign the value of $ihas to $ret
- if [ -n "$ihas" ] && [ -z "$ret" ]; then
- echo " +++ found:$ihas len:${#ihas}"
- ret="$ihas"
- fi
- done < <(iscsiadm -m session -P 3)
- # return the assigned device
- echo "$ret"
- }
- # call foo() and return the device
- bar=$(foo)
- echo "foo() returned value:$bar len:${#bar}"
- foo() returned value: read line:iSCSI Transport Class version 2.0-870
- read line:version 2.0-873
- read line:Target: 2017-01.ihost:ib-ssd-luns
- read line:Current Portal: 172.22.24.5:3260,1
- read line:Persistent Portal: 172.22.24.5:3260,1
- read line:**********
- read line:Interface:
- read line:**********
- read line:Iface Name: default
- read line:Iface Transport: tcp
- read line:Iface Initiatorname: iqn.1993-08.org.debian:01:b2c8ba7d76e3
- read line:Iface IPaddress: 172.22.24.7
- read line:Iface HWaddress: <empty>
- read line:Iface Netdev: <empty>
- read line:SID: 148
- read line:iSCSI Connection State: LOGGED IN
- read line:iSCSI Session State: LOGGED_IN
- read line:Internal iscsid Session State: NO CHANGE
- read line:*********
- read line:Timeouts:
- read line:*********
- read line:Recovery Timeout: 120
- read line:Target Reset Timeout: 30
- read line:LUN Reset Timeout: 30
- read line:Abort Timeout: 15
- read line:*****
- read line:CHAP:
- read line:*****
- read line:username: <empty>
- read line:password: ********
- read line:username_in: <empty>
- read line:password_in: ********
- read line:************************
- read line:Negotiated iSCSI params:
- read line:************************
- read line:HeaderDigest: None
- read line:DataDigest: None
- read line:MaxRecvDataSegmentLength: 262144
- read line:MaxXmitDataSegmentLength: 8192
- read line:FirstBurstLength: 65536
- read line:MaxBurstLength: 262144
- read line:ImmediateData: Yes
- read line:InitialR2T: Yes
- read line:MaxOutstandingR2T: 1
- read line:************************
- read line:Attached SCSI devices:
- read line:************************
- read line:Host Number: 154 State: running
- read line:scsi154 Channel 00 Id 0 Lun: 0
- read line:scsi154 Channel 00 Id 0 Lun: 1
- read line:Attached scsi disk sdc State: running
- +++ found:sdc len:3
- sdc len:1771
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement