CT320 HW5: File Tracker
Files appear and disappear. It’s all so hard to follow.
If only there were a program to help you keep track of things!
For this assignment, you will write a program called “
which helps you keep track of things. It can be a
bash script, a
perl script, or a
python3 script, but nothing else. This program is
useful for system monitoring.
It will tell you about any files underneath your home directory that
have appeared or vanished since the last time this program executed.
track output goes to standard output.
Only write to standard error for errors.
track would typically be executed from
cron, where the output
gets mailed to you. Of course,
track itself knows nothing about
track simply produces output or not.
emailing the output to you.
Here are some sample runs (
$ is my prompt):
$ touch ~/tmp/alpha
$ date >~/tmp/beta
$ sleep 60
$ cd src
$ echo "Hello" >>gamma
-rw------- 1 ct320 class 6 Oct 16 15:13 src/gamma
-rw------- 1 ct320 class 0 Oct 16 15:12 tmp/alpha
-rw------- 1 ct320 class 29 Oct 16 15:12 tmp/beta
$ rm ~/tmp/beta
$ cp /etc/group ~/vote-for-jack-in-the-year-65535
-rw------- 1 ct320 class 1021 Oct 16 15:13 vote-for-jack-in-the-year-65535
$ rm ~/tmp/alpha ~/vote-for-jack-in-the-year-65535
~/.track-info does not exist, that means that this is
the first run, so be silent.
- Otherwise, use
~/.track-info to keep track of what’s there.
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
- Don’t track file data; just remember of which files exist.
- This script must work for any user, no matter what their
username is, no matter what the path of their home directory is,
and no matter what their current directory is.
- Show changes since the previous run;
do not show all changes since the first run.
- Produce a message to standard error, including the name of the
file containing the script, upon any unexpected error, including:
- can’t read or write
- any arguments are given
- can’t access a directory (the message must name the directory)
- Produce no output the first time
track is executed.
- Only report files that have been created or removed—not those that
have merely had their data modified.
- If file
alpha gets renamed to
beta, that’s the same as
alpha and creating
- If either section (deleted or new files) is empty,
then nothing is printed for that section, not even a header line.
- Within a section, the files must be presented in sorted order by path.
- Display results for plain files only—ignore directories,
- Ignore any plain file whose name begins with a dot. For example:
- do not ignore
- Clean up any temporary files that you create.
- If you need to store data between runs, put it in
which may be a file or a directory. Your program must
~/.track-info, as needed. We won’t create it for you.
- Your output should be exactly the same as the output shown above,
if you were to modify those files at that time.
- Spaces matter (there are four leading spaces in the ls-like output).
- Did you notice how the filenames in a given section all lined up,
even when they had different sizes? That’s no accident.
Use web checkin, or:
~ct320/bin/checkin HW5 track
How to receive negative points:
Turn in someone else’s work.