Spring 2017 CSCI 373 Homework 9

This assignment is due by 5:10 PM Tuesday, 2 May.

Python prober

As you might have noticed, all the non-wimply Pi comptuers have hostnames like uncacsci-pi2-X.cs.unca.edu, or uncacsci-pi3-X.cs.unca.edu.

Your assignment is to write a Python script that checks out all 52 possibilities of the above hostnames and determine which hostnames have been assigned (using hostname) and are responding to using ping requests. To make the network administrators happy, use the following command when you ping.
    /bin/ping -i 0.3 -c 1 -w 1 uncacsci-piL-N.cs.unca.edu.

Do this using the Python’s subprocess module. You don’t have to read the output of ping. You just need to check if the return code is 0.

For each potential hostname, print if the hostname is up and running.

Once you get your program running correctly with ping, you should pipe the output of ping to /dev/null, conviently called os.devnull, so we don’t have to look at ping’s output. There are several Stack Overful posting that show you how to do this. I used the one from Martijn Pieters.

Suggested procedure

This is an incremental approach. Start with a simple program and expand it.

Turn in

Upload your Python program (no PDF) to the Homework 9 moodle page by 5:10 PM on Tuesday, 2 May.