- 论坛徽章:
- 0
|
脚本的目标是读主机IP列表,实现在本地主机上执行命令,收集远程主机上的配置信息。
perl 脚本如下:
#!/usr/bin/perl -w
while(<>){
chomp;
print "$_ SAN_MAP\n";
system('icmd -i' .$_. ' -c /sbin/sh /opt/hp/cms/sanmap20151113.sh');
print "$?\n";
#$output = `'/usr/bin/icmd -i $_ -c "/sbin/sh /opt/hp/cms/sanmap20151113.sh"'`;
#print "$output\n";
print "\n\n\n\n";
sleep 10;
}
脚本执行结果如下:
10.96.168.52 SAN_MAP
0
10.96.168.53 SAN_MAP
0
10.96.168.54 SAN_MAP
0
截断
shell 脚本可以正常执行,脚本和输出如下:
while read line
do
echo $line
echo "--------------------------------------------------------"
icmd -i $line -c 'sh /opt/hp/cms/sanmap20151113.sh|egrep -E "fcd16|fcd17|fcd22|fcd23"'
sleep 10
done < yya_ip
10.96.168.52
--------------------------------------------------------
/dev/fcd16 2/0/0/5/0/0/0 33,36 0x5001438021dd2b0c xxxxx ONLINE 33,32 DSM_READY 0x50060e80166e5704 93783 1E
/dev/fcd17 2/0/0/5/0/0/1 36,36 0x5001438021dd2b0e xxxxx ONLINE 36,32 DSM_READY 0x50060e80166e5714 93783 2E
/dev/fcd22 3/0/0/5/0/0/0 33,37 0x5001438021dd2b30 xxxxx ONLINE 33,33 DSM_READY 0x50060e80166e570c 93783 1N
/dev/fcd23 3/0/0/5/0/0/1 36,37 0x5001438021dd2b32 xxxxx ONLINE 36,33 DSM_READY 0x50060e80166e571c 93783 2N
截断
高手们有时间的话,请帮忙看看为什么perl的system无输出呢? |
|