CSCI 57 and 65: Introduction to Unix Courses
Laboratory Assignment 11
1. TURN-IN a hard copy of the following:
- On all homework please include
- Your Name
- Course Number
- Date
- ecst login name
- Please write the following scripts
- Write your second bash script, create a file named testscript and type in the following:
#!/bin/bash # this is the testscript by YOUR NAME
echo "The name this script was called with is $0 "
echo "The first argument this script was called with was: $1 "
echo "The first argument this script was called with was: $2 "
echo "The first argument this script was called with was: $3 "
echo "The first argument this script was called with was: $4 "
echo "The full list of parameters is in $@ "
|
Next, modify the permissions on this script so that you have execute permission on it, type chmod 755 testscript
Now run the script by typing ./testscript one two three or maybe by just typing testscript one two three
Include your name in the script. Turn-in a printout of the script.
- Write a script called clnet
- This script is for cleaning up some files generated by netscape
and for removing netscapes lock file when necessary.
- On your ecst account if you use netscape very much you will eventually
fill up your disk quota with netscape cache. A script like clnet
could be used to clean out all of these files and could be scheduled to run
regularly with cron (except we don't have access to cron at school)
- When this script is run without any arguments it should delete:
- ~/.netscape/cookies
- ~/.netscape/history.list
- ~/.netscape/history.dat
- ~/.netscape/cache/* (all files and directories under the
cache directory)
- When this script is run with the single argument "lock" (as in
clnet lock ) this script should remove netscapes lock file but none of
the other files. Netscapes lock file is located at ~/.netscape/lock
and is used to prevent multiple instances of netscape from running at the
same time.
- If this script is called with any other options it should print
a usage message and exit without deleting any files.
- I recommend writing this script using bash but you can use
any of the following if you prefer sh, csh, tcsh,
ksh. or perl.
- To run the script you will need to have execute permission on it
and have it in your PATH (or give the relative path on the command
line, if it was in your current directory you could type ./clnet).
- Please include one line of documentation
- # clnet script for deleting netscapes cache, history and lock
file - written by YOUR NAME
- (You can document it more if it helps you but one line similar
to above is all I care about).
- Include a print out of this script for your turn-in, make sure
it works.
Added: 4-27-2004 - I forgot to tell CSCI 65 how to
test for a null string.
Here is a snippet of code to play with:
if [ -z "$1" ]
then
echo "First argument was not passed"
fi
Here are my sample scripts also. The "strings" script
in particular gives examples similar to what is needed for
this assignment.
Finally, since I was slow in putting this up if you are
in CSCI 65 I can be a little flexible on this due date if
need be.
(Nobody has emailed me from 65 asking how to do the
above so I am not sure if everyone waits till the night
before anyway or if everyone was able to figure this out
pretty easily).