I'm trying to set up a "check if machines are online" script with Bash, but running into an issue of when and where to define the variables so they're expanded properly. Something like:
#!/bin/bash
rm01="c01 c02 c03"
rm02="d01 d02 d03"
rm10="e11 e22 e33"
for room in rm01 rm02 rm03; do
echo $room
for computer in $room; do
#run various nslookup/ping tests and report
done
done
exit 0
I'm running into issues because I can't find a way to expand $room
for its corresponding set of computers (in $rm01
, $rm02
, $rm10
) listed at the beginning.
What am I doing wrong?