NOTE: This assignment, like the other projects in this class, is due at a particular time, listed above. This means that if you are even a minute late, you lose 20%. If you are worried about potentially being late, turn in your project ahead of time. Do this by submitting it electronically before the due date (the electronic copy is what is due by the time given above) then giving the hard copy to me or the TA during office hours or by sliding it under my office door (the hard copy is due within twenty-four hours after the electronic copy is due). Do not send assignments to my personal email address or to the personal email address of the TA. Do not leave hard copies in my departmental mail box or attempt to give them to departmental staff (who cannot and will not accept them).
As discussed in class, the common scp
utility has the same
types of drawbacks as the cp
utility when it comes to
interactive use but with scp
these drawbacks are even more
pronounced. This is because scp
lacks even the rudimentary
interactive flag found in most modern versions of cp
(in fact,
scp
uses -i
to mean something else entirely) and
because obtaining useful information to decide on file replacement is even
more difficult across the network than it is on the same machine.
Typically, if one is copying a file to a remote machine and overwriting an
existing file is a concern, one would need to remotely login to the
machine (using, for example, ssh
) and check for the file's
existence and properties before even attempting to use scp
.
Clearly, this is not ideal.
One modification to scp
that people might find useful,
then, is one that assists them in obtaining the information they need in
order to make intelligent decisions regarding overwriting or deleting
files.
For this assignment, we'll implement our own version of scp
that provides the same type of interactive mode for scp
that
we provided for cp
in Project 3. This interactive mode will
be selected using the -I
flag.
To interactively copy one file or directory the user will type:
scp -I <source> <destination>where
<source>
is the "Internet pathname" (either
absolute or relative) for the file or directory that the user wishes to
copy and <destination>
is the "Internet pathname" to
which the user wishes to copy <source>
.
By "Internet pathname" we will mean a name of the form
[[<username>@]<hostname>:]<pathname>
, where
<username>
is a user's login name,
<hostname>
is either the name of a networked host that
can be looked up in a relevant Domain Name Server or its IP address, and
<pathname>
is the name of the path (possibly including
the filename) of the file or directory in question.
Note that parts of the "Internet pathname" in square brackets [] are
optional. If <username> is omitted, the name of the user issuing the
scp
instruction on the machine where the instruction was
issued should be used. If <hostname> is omitted, the name of the
machine where the instruction was issued should be used.
For example, to interactively copy the file file1
found in
the home directory of user1234
on gpel1.cs.ou.edu
to the /tmp
directory on apollo2.cs.ou.edu
under the ownership of talk6789
, one could type:
scp -I user1234@gpel1.cs.ou.edu:file1 talk6789@apollo2.cs.ou.edu:/tmpNote that this should work as long as the user knows the passwords (or there is automatic authentication set up as needed) for user1234 on gpel1 and talk6789 on apollo2, regardless of whether the user was actually issuing this instruction from either of these accounts on either of these machines.
For a second example, consider that a user wishes to copy the file
file21
from the subdirectory sub44
of her home
directory on hamming.cs.ou.edu
to a file of the same name in
the present working directory of the machine on which the instruction is
issued. In this case, we are assuming that the user's username is the same
on both machines and may, therefore, be omitted. This user could type:
scp -I hamming.cs.ou.edu:sub44/file21 .
When invoked in this way, scp
will check to see whether a
file or directory with the Internet pathname
<destination>
already exists, then provide information
to the user and prompt for action appropriately, as was done with
cp
in Project 3.
To interactively copy multiple files or directories the user will type:
scp -I <source_1> <source_2> ... <source_n> <destination>where
<source_1>
, <source_2>
, ...
<source_n>
are the Internet pathnames (either absolute
or relative) for the files or directories that the user wishes to copy and
<destination>
is the Internet pathname of the directory
to which to which the user wishes to copy each
<source>
.
When invoked in this way, scp
will check to see whether
<destination>
is, in fact, a directory. If it is not,
scp
will give the error message:
scp: when moving multiple files, last argument must be a directoryIf
<destination>
is a directory, scp
will
proceed as though invoked as above one time for each
<source_i>
.
While a production version of this software should handle all
communications between machines using encryption and appropriate
authentication (e.g., password protection), you do not need to worry about
these issues for the communication used for gathering data for intelligent
decision-making regarding overwriting. That is, you may use your own
server and client software that does not use encryption or authentication
to communicate information such as a file's existence, size, modification
date, etc. However, you should ensure that all modifications to the remote
file system do use encryption and appropriate authentication. This could
be easily accomplished by having your custom client software invoke the
standard scp
utility program to actually copy the file(s),
after the interaction requested by -I
was completed.
Some parts of the assignment above may be vague or incomplete. This is intentional. This is to give you experience with the way software development is done in "the real world" (industry, academia outside the classroom, government labs, etc.). Often you will get problem descriptions that are vague or incomplete, even if they seem concrete and complete initially.
You should read through the assignment carefully, look for ambiguities or cases not covered, then ask about them, either in office hours or through email, as soon as you can. (Recall that those people who come to office hours get priority over those who call during office hours who, in turn, get priority over those who send email.) If you wait until the last minute to ask about ambiguities or missing cases, you may not get an answer before your project is due. If you don't get an answer in time (or at all, if you don't ask), then you will have to guess how to handle certain situations. If you guess wrong, you will lose points.
You will turn in both a hard copy and an electronic copy of your assignment. Please follow the instructions on how to send electronic copies. Do not send them to my email address.
Both the hard copy and the electronic copy will contain a write-up and
all source code you used in this project. The electronic copy will also
contain the executable versions of your code. The electronic copy of your
write-up should not be in a proprietary format (such as MS Word); it should
be either in plain ASCII text or in a portable format (such as Postscript
or PDF). Your source code should be in two files called scp.c
(for C code) or scp.cxx
(for C++ code) and your executable
files should be called scp
.
Your source code should be well structured and well commented. It should conform to good coding standards (e.g., no memory leaks).
Your write-up will include 1/2 to 1 page (roughly 80 characters per line, 50 lines per page) explaining the data structures and algorithms used in your code. This page limitation does not include figures used in your explanation, which are encouraged and may take up any amount of space. (This explanation does not remove the requirement that your code be well commented.)
You may write your program from scratch or may start from programs for which the source code is freely available on the web or through other sources (such as friends or student organizations). If you do not start from scratch, you must give a complete and accurate accounting of where all of your code came from and indicate which parts are original or changed, and which you got from which other source. Failure to give credit where credit is due is academic fraud and will be dealt with accordingly.
As noted in class, you are NOT required to work on this programming assignment in a group of at least two people. However, for purposes of grade calculation, a minimum group size of two will be used for each group even if that "group" includes only a single member. It is your responsibility to find other group members and work with them. The group should turn in only one (1) hard copy and one (1) electronic copy of the assignment. Both the electronic and hard copies should contain the names and student ID numbers of all group members. If your group composition changes during the course of working on this assignment (for example, a group of five splits into a group of two and a separate group of three), this must be clearly indicated in your write-up, including the names and student ID numbers of everyone involved.
Each group member is required to contribute equally to each project, as far as is possible. You must thoroughly document which group members were involved in each part of the project. For example, if you have three functions in your program and one function was written by group member one, the second was written by group member two, and the third was written jointly and equally by group members three and four, both your write-up and the comments in your code must clearly indicate this division of labor.