Changes

Jump to: navigation, search

OPS235 Lab 6 - CentOS7 - SSD

401 bytes added, 15:20, 14 June 2016
no edit summary
<br>
WE 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.<br><br>
<ol><li value="5">Add the following content to your shell script editing session:</li></ol>
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;&nbsp;&nbsp;$x[$index]="$line"<br>
&nbsp;&nbsp;&nbsp;index=$(($index+1))<br>
&nbsp;done < /tmp/network-$x.txt$$<br>
done<br>
</code>
<br>
 
Finally we will use a loop to printout the results of the data (stored in the Associative Arrays) in a report file called: /root/network-info.txt
The command at the end is a trick to remove all temporary files that have the same extension as the current PID number, therefore, it is unique.
<br><br>
<ol><li value="6">Add the following content to your shell script editing session:</li></ol>
 
 
13,420
edits

Navigation menu