我正在尝试使用 cli 命令捕获多个远程设备的输出,然后使用 grep 717GE 并打印到多个主机的屏幕。正如您在下面看到的,它从 $hosts 捕获 IP 并将其传递给 $outip,而不是在命令行中使用相同命令时显示的内容。我认为该变量将捕获从给定命令返回的数据。有人可以帮助我并帮助我了解我做错了什么吗?我真的对学习很感兴趣,所以请不要发表刻薄的评论。如果可能的话。
for host in ${hosts[@]}; do
seven=( $(cli $hosts show gpon ont summary -n --max=3 --host ) )
outip=( $(grep 717GE $seven) )
echo $outip
done
输出:
+ for host in '${hosts[@]}'
+ seven=($(cli $hosts show gpon ont summary -n --max=3 --host ))
++ cli 10.100.112.2 show gpon ont summary -n --max=3 --host
+ outip=($(grep 717GE $seven))
++ grep 717GE 10.100.112.2 grep: 10.100.112.2: No such file or directory