Open main menu

CDOT Wiki β

Changes

OPS235 Lab 6 - CentOS7 - SSD

827 bytes added, 16:17, 14 June 2016
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;">
&nbsp;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>
&nbsp;read -p "Enter regular username for \"$x\" server: " userName[$x]<br>
&nbsp;ssh ${userName[$x]}@$x "cat /etc/network/interfaces" > /tmp/network-$x.txt<br>
<br>
&nbsp;index=0 # load each line into an array for VM<br>
&nbsp;while read line<br>
&nbsp;do<br<
&nbsp;&nbsp;&nbsp;$x[$index]="$line"<br>
&nbsp;&nbsp;&nbsp;index=$(($index+1))<br>
&nbsp;done < /tmp/network-$x.txt<br>
done<br>
</code>
<br>
13,420
edits