- 论坛徽章:
- 2
|
[root@ops-72 ~/zx/guobao]# dmidecode -t system|awk /Product/'{print $3,$4,$5,$6}'/Serial/'{print $1,$2,$3}'
VMware Virtual Platform
Serial Number: VMware-42
执行如下:
[root@ops-72 ~/zx/guobao]# ./IP_and_SN.sh
awk: /Product/{print ,,,}/Serial/{print ,,}
awk: ^ syntax error
awk: /Product/{print ,,,}/Serial/{print ,,}
awk: ^ syntax error
awk: /Product/{print ,,,}/Serial/{print ,,}
awk: ^ syntax error
awk: cmd. line:1: /Product/{print ,,,}/Serial/{print ,,}
awk: cmd. line:1: ^ unexpected newline or end of string
脚本编写如下:
[root@ops-72 ~/zx/guobao]# cat IP_and_SN.sh
#!/bin/bash
>SNN.txt
for ip in `cat ip.txt`
do
#SN=`ssh $ip "dmidecode -t system|grep -Ei 'Product|Serial'"`
SN=`ssh $ip "dmidecode -t system|awk /Product/'{print $3,$4,$5,$6}'/Serial/'{print $1,$2,$3}'"`
echo $SN >>SNN.txt
done
[root@ops-72 ~/zx/guobao]# |
|