Hello,
I have having problems with an assignment and am pretty desperate. My assignment is to create a shell script that does a Recycle_Bin tasks. You can only open this with PuTTY software or Knoppix. Perhaps on other software that are able to read linux language.
My part is stuck in accepting the date values and use those values into the next command based on which option the user selects.
recycle_bin [ -dyymm ] [ -yyy ] [ -mmm ] [-h] [-c] [-v] [directory]
Have enclosed details of my assignment below and the code that i have done so far in a following post.
Thanks in advance for any help recieved
Details of the Assignment are as follows:
The aim of this assignment is to develop a shell script (Bourne Shell syntax) which meets the following specification.
Develop a script which performs the function of a recycle bin.
However, this recycle bin utility takes a date as an argument and a directory and moves all those files in that specified directory that are not modified after the specified date, to a directory called recycle under your home directory.
In other words, all those files which are older than the specified date are moved to the recycle directory.
Of course, if the recycle directory does not exist, then the script should automatically create one, possibly with a message to the user.
The date and the directory name may be specified in a variety of formats as shown below.
However, if the directory is not specified, then use the current working directory.
In addition to these arguments, there are other valid arguments that can be specified to the script
whose meaning is described in the following.
Usage:
recycle_bin [ -d yymm ] [ -y yy ] [ -m mm ] [-h ] [ -c ] [ -v ] [directory]
OR
recycle_bin [ -dyymm ] [ -yyy ] [ -mmm ] [-h ] [ -c ] [ -v ] [ directory ]
The difference between the above two syntax is the way a value to an argument is
specified. In the first form the argument and the value are separated by one or more space or tab. Choose one of these syntax for implementation (choose the one that is easy to implement!).
The semantics of the options are:
� A date can be specified either as -d yymm (year and month in digits, e.g. 0903) or, -y yy
(year) or -m mm (month). The current year will be used, if year is not specified (namely when
-y or -d option is not specified). Similar assumption can be made for month, if required. Also
assume that year and month specifications are independent.
2 of 4
� -h option - head option, if specified will display the first 5 lines of the file that will be moved
to the recycle directory. Optionally after displaying the top 5 files, you can ask the user to
confirm the move (Microsoft style).
� -c option prints a final count of the number of files that is moved to the recycle directory.
� -v option invokes the script in verbose mode - it lists the name and the date of last
modification for each of the file that is being moved (see the examples below).
� -x option (no value to this option) prints one line on how to use the script (basically listing
the above syntax ).
Of course a user need not specify all the options while invoking the script, in which case, you need to assume default values for the missing options. Clearly state your default value for each of the options for your script.
Examples (In the following examples, the command is given in italics and the output
in bold):
$ recycle_bin -y08 -v UnixPrograming
or
$ recycle_bin -y 08 -v UnixProgramming
(Move files which are modified before March 2008,
assuming March is the current month as -m option is not
specified from the UnixProgramming directory - which has
to be a sub-directory of the current directory and print
the last modification of each of the file that is movedbecause
of -v option)
exercise1: modified 2007 MAY moved
trial: modified 2001 JAN moved
core: modified 2003 FEB moved
exercise5: modified 2004 DEC moved
$ recycle_bin -d0902 -c Tutorial
(Non-verbose mode, but display a count of files moved)
10 files moved
$ recycle_bin -m02 -h -c
(same as above + display top 5 lines of each file that is moved)
file1: modified 2003 JAN
This is a test file
It does not contain any useful information
Created to practice vi editing
3 of 4
(2 more lines will be displayed, if exists)
move file1 [y/n]? y
temp.c: modified 2006 JAN
/* Checking the character operations */
int main()
{
char c;
move temp.c [y/n]? y
2 files moved
$ recycle_bin -x
Usage: recycle_bin [ -d yymm ] [ -y yy ] [ -m mm ]
[-h ] [ -c ] [ -v ] [ directory ]
$
Testing and evaluation:
You need to devise a test plan to test the script. For each test data, you need to specify which
part of the script will be tested, what action/output is expected and what was actually outputted.
Also you need to justify that your test plan has tested your program fully (all the parts of the
script).
In order to test your program, you need to create some dummy files with various creation dates.
You can use the touch command to change the modification date of a file. See the manual
page for touch.