DevOps virtualization
In this assignment you will develop some simple bash shell scripts to allow you to automate repetetive tasks. You will also review other shell commands.
Begin by developing a shell script that will search for files within a directory whose name contains a space. Your script should replace all spaces in a filename with an underscore.
Here is some pseudocode to help you solve this:
Write a shell script that will read some lines of an input file which contains host names of various machines (see here). Note that you will have to parse the file to pull out the hostnames. This example could help you get started. Note that when you run the script it may try to ssh into the different hosts. To make it so it doesn’t prompt you for a password for each machine, you should do something like ssh-copy-id oxygen
before running the script. You may have to answer ‘yes’ to connect to each host the first time you run the script.
If the 119 file doesn’t have many responsive hosts, you could also try this file.
Your script should ssh
to the machines in question and gather the following pieces of information:
Your script should create a new file for each machine that has the above information in it. The filename should be something like krypton_stats.txt
where krypton
is the name of the host. The filename should only be created if the host actually responds to a ping.
The content of the file you create should have the format that looks like this:
1545 megabytes of memory out of 7893 are available
There are 2 users currently logged in
This will be passed off in class. You will run your script and show me that it works.