This assignment is due by 5:10 PM Tuesday, 2 May.
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
You don’t have to read the output of
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
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.
This is an incremental approach. Start with a simple program and expand it.
- Write a Python program to enumerate all 56 possible names.
- Write a Python program that enumerates the 56 possible argument lists,
shlex.splitfor calling ping with each hostname.
- Write a Python program that calls ping with each hostname.
- Write a Python program that checks the return code for each call of ping.
Upload your Python program (no PDF) to the Homework 9 moodle page by 5:10 PM on Tuesday, 2 May.