13,420
edits
Changes
no edit summary
#Open a shell terminal and login as '''root'''.
#Change to the '''/root/bin''' directory.
#Using a text editor, create a Bash shell script called '''network-info.bash''' and enter the following content below:<br><br>x<br><br>
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
exit 1<br>
fi<br>
</code>
<br>
WE will now use an Associative Array along with the ssh command in order to get and store networking configuration from the '''centos1''', '''centos2''', and '''centos3''' VMs.
<ol><li value="5">Add the following content to your shell script editing session:</li></ol>
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
<br>
set centos1 centos2 centos3<br>
for x<br>
do<br>
read -p "Enter regular username for \"$x\" server: " userName[$x]<br>
ssh ${userName[$x]}@$x "cat /etc/network/interfaces" > /tmp/network-$x.txt<br>
<br>
index=0 # load each line into an array for VM<br>
while read line<br>
do<br<
$x[$index]="$line"<br>
index=$(($index+1))<br>
done < /tmp/network-$x.txt<br>
done<br>
</code>
<br>