- 论坛徽章:
- 0
|
请教大家几个问题:
1.getmac()里面的这两行是什么意思:
ethhw=$(ifconfig $1 | grep HWaddr)
ethhw=${ethhw##*HWaddr }
2.getcpu()里面的这行是什么意思:
"$cpuinfo" >> $1
3.getdisk()里面的这行是什么意思:
diskinfo=${diskinfo##*SerialNo=}
先谢过啦!脚本见下面:
-------------------------------------shell-------------------------------------
getmac()
{
ethhw=$(ifconfig $1 | grep HWaddr)
if [ "$ethhw" != "" ];
then
ethhw=${ethhw##*HWaddr }
echo "$1 $ethhw" >> $2
fi
}
getcpu()
{
cpuinfo=$(grep "model name" /proc/cpuinfo)
echo "$cpuinfo" >> $1
}
getdisk()
{
diskinfo=$(hdparm -i /dev/$1 | grep SerialNo)
if [ "$diskinfo" != "" ];
then
diskinfo=${diskinfo##*SerialNo=}
echo "$1 $diskinfo" >> $2
fi
}
case $1 in
-f)
true > $2
case $3 in
-mac)
getmac eth0 $2
;;
-disk)
getdisk hda $2
getdisk hdb $2
getdisk hdc $2
getdisk hdd $2
getdisk hde $2
getdisk hdf $2
getdisk sda $2
getdisk sdb $2
getdisk sdc $2
getdisk sdd $2
getdisk sde $2
getdisk sdf $2
;;
-cpu)
getcpu $2
;;
*)
getcpu $2
getmac eth0 $2
getmac eth1 $2
getmac eth2 $2
getmac eth3 $2
getmac eth4 $2
getmac eth5 $2
getmac eth6 $2
getmac eth7 $2
getdisk hda $2
getdisk hdb $2
getdisk hdc $2
getdisk hdd $2
getdisk hde $2
getdisk hdf $2
getdisk sda $2
getdisk sdb $2
getdisk sdc $2
getdisk sdd $2
getdisk sde $2
getdisk sdf $2
;;
esac
;;
*)
;;
esac |
|