#!/bin/bash
range=$(seq -f "cen%04g" 1052 1099)
range1=$(seq -f "rh%04g" 1052 1099)
check () {
for node1 in ${range};do
ping -q -c 1 -w 3 -s 10 $node1 >/dev/null
if [ $? -eq 0 ];then
$i_up+=(${node1}",")
else
$i_down+=(${node1}",")
fi
done
}
for i in "site1" "site2" "site3"
do
declare -a $i_down
declare -a $i_up
check &
done```
1, I'm not sure how can I name the array based on for loop input so that it can run sites(site1,site2,site3) in parallel and get the array input in separate for each site. Else running each will take longer time.
2, I have range on series cen(1052 to 1099) and if its not found there, I need to check with different series(rh) with same numbers. eg: cen1052 isn't there it needs to check rh1052. how can do that.
ARthur done
- I'm not sure how can I name the array based on for loop input so that it can run sites(site1,site2,site3) in parallel and get the array input in separate for each site. Else running each will take longer time.
- I have range on series cen(1052 to 1099) and if its not found there, I need to check with different series(rh) with same numbers. eg: cen1052 isn't there it needs to check rh1052. how can do that.