rcon1
January 7, 2008, 11:14am
1
Below is part of a script i have written to loop through part of a port info file. How do i continue the script to get info for OS Device Name, manufacturer and then put information into an array?
HBA Port WWN: 10000000c9420b4b
OS Device Name: /dev/cfg/c10
Manufacturer: Emulex
Model: LP10000DC-S
Firmware Version: 1.92a1
FCode/BIOS Version: none
Type: N-port
State: online
Supported Speeds: 1Gb 2Gb
Current Speed: 2Gb
Node WWN: 20000000c9420b4b
#!/bin/ksh
PORT_INFOFILE=/tmp/aa
if [ -f $PORT_INFOFILE ]; then
rm -f $PORT_INFOFILE
touch $PORT_INFOFILE
fi
# read port info
fcinfo hba-port >> $PORT_INFOFILE 2>&1
cat $PORT_INFOFILE | while read line; do
x=\`echo $line | grep "HBA Port"\`
if [ -n $x ]; then
NEW_PORT="TRUE"
else
NEW_PORT="FALSE"
fi
Here is simple framework you can work with.
#!/bin/ksh
cat data | while read one two
do
case $one in
"HBA" ) echo "HBA is $two"
;;
* ) echo "one=[$one] two=[$two]"
;;
esac
done
$ ./parse.file
HBA is Port WWN: 10000000c9420b4b
one=[OS] two=[Device Name: /dev/cfg/c10]
one=[Manufacturer:] two=[Emulex]
one=[Model:] two=[LP10000DC-S]
one=[Firmware] two=[Version: 1.92a1]
one=[FCode/BIOS] two=[Version: none]
one=[Type:] two=[N-port]
one=[State:] two=[online]
one=[Supported] two=[Speeds: 1Gb 2Gb]
one=[Current] two=[Speed: 2Gb]
one=[Node] two=[WWN: 20000000c9420b4b]
actually. this is even better and gives you an array like you wanted.
#!/bin/ksh
cat data | while read line
do
set -A array $line
echo "array[0]=${array[0]}"
echo "array[1]=${array[1]}"
# ... you get the point
echo
done
porter
January 7, 2008, 6:35pm
4
or this..
while read line
do
...
done <data
rcon1
January 9, 2008, 5:59am
6
cheers! thanks for the comments