Datasheet

52
Phase 1
Working on the Command Line
If you enter Listing 1.6 and call it safercp, you might use it like this, assuming the file
original.txt exists and dest.txt does not:
$ ./safercp original.txt dest.txt
$ ./safercp original.txt dest.txt
Target file exists! Exiting!
The first run of the command succeeded because dest.txt did not exist. When the com-
mand was run a second time, though, the destination file did exist, so the program terminated
with the error message.
Note that the functions are not run directly and in the order in which they appear in the
script. They’re run only when called in the main body of the script (which in Listing 1.6 con-
sists of just two lines, each corresponding to one function call).
Criteria for Completion
To complete this task, you must have created five scripts to perform the five tasks outlined ear-
lier. I recommend that you try some simple variants on these tasks so that you create scripts
that perform other tasks—for instance, you might modify Listing 1.5 so that it displays graph-
ics files in a directory rather than plays audio files.
83484.book Page 52 Monday, September 18, 2006 8:58 AM