CT320 HW5: File Tracker
Motivation
Files appear and disappear. It’s all so hard to follow.
If only there were a program to help you keep track of things!
                
Summary
For this assignment, you will write a program called “track
”,
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.
                
Output
Normal 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
email—track
simply produces output or not. cron
handles
emailing the output to you.
                
Sample Runs
Here are some sample runs ($
is my prompt):
                
$ cd
$ ./track
$ touch ~/tmp/alpha
$ date >~/tmp/beta
$ sleep 60
$ cd src
$ echo "Hello" >>gamma
$ ~/track
New:
-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
$ ~/track
Deleted:
tmp/beta
New:
-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
Deleted:
tmp/alpha
vote-for-jack-in-the-year-65535
$ ~/track
$
~/.track-info
- If
~/.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.
Debugging
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
Hints
- 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.
Requirements
- 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
~/.track-info
.
- 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
deleting alpha
and creating beta
.
- 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,
symlinks, etc.
- Ignore any plain file whose name begins with a dot. For example:
- ignore
foo/42/.zip
- do not ignore
.glorp/177777
or iota/.ajbaxah/bozo
.
- Clean up any temporary files that you create.
- If you need to store data between runs, put it in
~/.track-info
,
which may be a file or a directory. Your program must
create ~/.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.
Submission
Use web checkin, or:
                
~ct320/bin/checkin HW5 track
How to receive negative points:
                
Turn in someone else’s work.