Course Home | Syllabus | Schedule | Readings | Downloads | Submissions | [print]

Scripting Exam

Part 1

This script will parse a file that is given to you. The resultant data will be a bunch of ip addresses. You will loop through each ip address and ping the machine to see if it is up or not. (Hint: To do an easy ping, you should do ping -c 1 $ip. This will ping a single time.) If the machine responds to the ping, you should print alive to the terminal, otherwise print dead.

Your script should be named Your script should receive the filename to parse either as a command line argument or via standard input (i.e. ./ have_found.txt or ./ < have_found.txt). You can choose which method you would like to use.

You can manually download the file you need to parse here. You can also manually remove the first line of that file. Assuming my new file I downloaded is called have_found.txt and I have removed the first line, I would then begin my script by looping through each line and getting the ip. While still in the loop, do the ping test and display the appropriate output.

Part 2

This should be completed on a virtual machine of your choosing. Your virtual machine should be configured to login to without the use of passwords. (Copy your keys over there. Do this as your normal user)

Your script should login to php (via the use of keys) and check to see if some program is running or not. If the program is running, your script should display an appropriate message, if not, also display a message.

Your script should be named It should expect a command line argument with a process name to check for. (I.e. ./ apache2)

You could run your script to test for apache2 and it should give you a positive response. You could run your script to test for nginx and it should give you a negative response.

Hints: (If these don’t make sense, you can safely ignore)

Last Updated 12/22/2020