CT320 HW4: You up?
Individual Work
Work on your own!
                
Description
For this assignment, you will write a perl script called up
.
                
The purpose of this assignment is to have an easy way to verify that a
remote system is “up” (responds to pings). The command is designed so
that you can use it from cron. It is not much more than a thin veneer
around ping.
                
You give it a hostname, and it pings the host. It displays the
hostname, followed by how many ping packets came back, followed by how
many ping packets were sent.
                
Arguments
The script takes two optional arguments and a mandatory single hostname:
                
-s
: be silent. If all ping packets succeeded, display nothing.
-n
count: How many packets to send (see ping -c
).
Examples
In these sample runs, our computer denver.cs.colostate.edu
responds
to pings, but hp.com
doesn’t. “$
” is my shell prompt:
                
$ ./up denver.cs.colostate.edu
denver.cs.colostate.edu 3/3
$ ./up -n1 denver.cs.colostate.edu
denver.cs.colostate.edu 1/1
$ ./up -n2 -s denver.cs.colostate.edu
$ ./up hp.com
hp.com 0/3
$ ./up -s -n 10 hp.com
hp.com 0/10
$ ./up 192.0.2.12
192.0.2.12 0/3
Note
Wondering what the heck 192.0.2.12 is?
Read https://wikipedia.org/wiki/Reserved_IP_addresses#IPv4.
                
Debugging
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
Requirements
- We will test your program on a computer configured similarly
to the ones in the CSB 120 Linux Lab.
- Name your script simply “
up
”, not up.txt
, up.pl
,
or up.perl
.
- The first line of your script must start with:
#! /usr/bin/perl
- You may not use any external programs, other than ping.
- You must use the external ping command to do the actual pinging.
- Don’t use the
Net::Ping
module.
- Don’t use any other module to do the pinging, either.
- The space between
-n
and count is optional.
However, nothing else can be between them.
- The options may come in any order. The hostname must be last.
- Any error message must go to standard error,
and stop the program—no more output.
- Any syntactic error in the arguments or options should produce a usage
message to standard error, include the name of the program, as
invoked, which briefly describes how to correctly use the command.
- If the host can’t be found, produce an error message.
- Your output must match the example output shown above.
This is not the place for creativity.
- Don’t produce any extra output. It is not an adequate defense
to say “The
ping
command produced that; it’s not my fault."
How to submit your homework:
Via web checkin, or:
                
~ct320/bin/checkin HW4 up
How to receive negative points:
Turn in someone else’s work.