Using Drop to Transfer Files

The drop command that I created is a general-purpose tool that transfers one file at a time to a destination. It transfers ownership of the file to the recipient, so that they can do with it whatever they want.

Think of this as like a physical drop box or like sliding an assignment under someone's door.

We can do this both from student pairs to the CS 204 course account and from student to student.

In this explanation, I'm going to imagine that Hermione and Ron have worked together on an assignment using Hermione's account. Afterwards, they want to transfer the finished tarfile to Ron's account.

So, Hermione is the sender and Ron is the recipient.

Create a Drop Folder

To allow someone to drop a file to you, you have to create a drop folder in your home directory. This gives you a known place to look for files, and means that the sender can't drop them just anywhere in your account. So, do this first:

mkdir ~/drop

Ron needs to do this so that Hermione can drop a file to him.

Setting up a drop folder only needs to be done once, no matter how many files get dropped later.

Feel free to do an ls on the drop folder for the course account: ~cs204/drop. You'll see your solution to the unix assignment.

Create the Tar File

Typically, your assignment will be a folder in your cs204-assignments folder, such as mobile. To transfer all those files to your partner one at a time would be tedious at best. tar makes this much easier:

cd ~/public_html/cs204-assignments
tar cf mobile.tar mobile

This creates mobile.tar out of the mobile subdirectory. Adjust depending on the assignment.

Drop the File

Then, Hermione can drop the tarfile to Ron. Here's the command in action (here cs204guest is dropping a file to gdome):

[cs204guest@tempest ~]$ drop gdome mobile.tar 
Copying mobile.tar (from cs204guest) to /students/gdome/drop/ (uid 707)
/students/gdome/drop/cs204guest doesn't exist, making it.
Successful drop.

Structure and Permissions

If Hermione (cs204guest) is anxious and wants to be sure that the file is really there in Ron's (gdome's) drop folder, she can list the files that she has dropped:

[cs204guest@tempest ~]$ ls -l ~gdome/drop/cs204guest/
total 20
-r--r-----. 1 gdome cs204guest 20480 Sep  5 12:34 mobile.tar

Ron (gdome) can also check that it's there:

[gdome@tempest ~]$ ls -l ~/drop/cs204guest/
total 20
-r--r-----. 1 gdome cs204guest 20480 Sep  5 12:34 mobile.tar

You'll note in this example that there's a cs204guest (hermione) subfolder to Ron's (gdome's) drop folder. Think of that as "these are my files from Hermione". Each sender gets a subfolder with their account name. The drop command does this automatically.

This scheme allows each of the CS 204 students to drop a file called unix.tar to the course account and not step on each other. It also means that, next time, when Ron is working with Harry on a different assignment, Harry can drop the work to Ron and it'll go in the hpotter subfolder of Ron's drop folder.

Again, the subfolders are named for the sender.

You'll also notice, above, that the mobile.tar file in Ron's drop folder is owned by gdome (Ron), not by Hermione. The drop command has transferred ownership.

One consequence of this is that Hermione can't delete the file after she has dropped it. If she needs to drop it again, either Ron has to delete the earlier one (since he's the owner) or Hermione needs to rename the file and drop that:

mv mobile.tar mobile-revised.tar
drop rweasely mobile-revised.tar

That's it!

Summary

  1. Ron (once) creates a ~/drop/ folder
  2. Ron's partners can drop files, such as tar files, to him.
  3. The files go in subfolders named for the partner (sender)