gpt4 book ai didi

regex - 在 cmdshell 中解析 fcinfo 输出

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:00 25 4
gpt4 key购买 nike

我有以下输出,我正在尝试像这样解析

PS C:\Users\Administrator> fcinfo /details

adapter: com.microsoft-Virtual Fibre Channel HBA-0
node_wwn: c0:03:ff:00:00:ff:ff:00
fabric: 00:00:00:00:00:00:00:00
port_wwn: c0:03:ff:58:b6:20:00:02
osdevice: \\.\Scsi1:
venid: x0
prodid: x0

但我看不到使用下面代码的清晰解析

my $listHBAs = `fcinfo /details`;
my @lines = split(/\n/,$listHBAs);
my $wwns;
foreach (@lines) {
if($_ =~ /port_wwn \s+ : (.*)$/){
&runSsh($arrayIP, "$ig --wwpn $1");
}
}

最佳答案

您的正则表达式与您提供的输出不匹配,并且您通过不必要的预处理(即 split)使事情变得有些复杂。

my $listHBAs = `fcinfo /details`;
while ($listHBAs =~ /port_wwn\s*:\s*(\S*)$/gm) {
&runSsh($arrayIP, "$ig --wwpn $1");
}

如果您只执行一个port_wwnif 将与while 一样好。

关于regex - 在 cmdshell 中解析 fcinfo 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25274301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com