Hello, I am trying to retrieve a list of ssg hosts on my network via ping. I want to put the list into a single variable if possible, but I can't seem to figure out how to do this.
What I used to do is put them into a file, but I wanted to see if there was a way to put them all into the same variable instead.
Here is the format that I am using to do this, which is incorrect, as each time the variable is going to become whatever host was last $i
Code:
[techs@ts-01 ~]$ for i in `cat /etc/storelist | awk '{print $1}'`
> do
> ping -c 1 $i-ssg > /dev/null 2>/dev/null
> pingRet=$?
> if [ $pingRet -eq 0 ]; then
> ssgHost=`echo $i`
> fi
> done
I'm hoping there is a command available that handles this sort of thing. I am killing my brain trying to figure out how to make it work by tossing variables around:
i.e.
Code:
oldVar=`echo $newVar`
newVar=`echo $i`
bothVar=`echo $oldVar && echo $newVar`
allVar=`echo $bothVar && # here I'm stuck in logic, intellect and patience
If this variable tossing can work, I cannot seem to see the solution. I was hoping to get some input on this.
Thanks in advance.