![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help needed | nnayagam | Shell Programming and Scripting | 2 | 03-07-2008 06:34 AM |
| Little help needed. | Netghost | AIX | 5 | 08-10-2006 02:29 PM |
| Help needed | dsravan | Shell Programming and Scripting | 2 | 07-20-2006 09:37 AM |
| awk help needed. | cskumar | Shell Programming and Scripting | 0 | 07-20-2006 07:24 AM |
| Sed help needed | stevefox | Shell Programming and Scripting | 5 | 12-05-2005 01:44 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help needed please.
i've been given an assignment to Write a system utility called recycle that satisfies the following requirements as they might be displayed in a UNIX/Linux man page:
NAME recycle - stores files in a recycle bin SYNOPSIS recycle [OPTION] ... [FILE] DESCRIPTION Recycle is a replacement for the rm system utility and simulates the Recycle Bin found on Windows systems. Rather than removing files, it moves them into a subdirectory located in your home directory called .recyclebin. If recycle is called without any parameters it displays the contents of the .recyclebin directory if it exists and tells the user there is no recycling available if it does not exist. OPTIONS Command line options are explained below. Only one option can be used for each call to recycle. –a add a file for recycling. If this -a option is used and there is no .recyclebin directory, recycle notifies the user, automatically creates the directory and moves the file to .recyclebin -e removes all files from .recyclebin and prints a message saying that the recycle bin is empty. -h prints out a short usage message with showing the options Here is a use case showing recycle at work: $ ls –l *.c # list existing C source files -rw-r--r-- 1 usr user 31 foo1.c -rw-r--r-- 1 usr user 31 foo2.c $ recycle No recycling exists $ recycle -a foo1.c .recyclebin does not exist. Creating the .recyclebin directory and adding the file now… $ ls –l foo1.c foo1.c not found $ recycle -a foo2.c $ ls -l foo2.c foo2.c not found $ recycle -rw-r--r-- 1 usr user 31 foo1.c -rw-r--r-- 1 usr user 31 foo2.c $ recycle -e The recycle bin is empty $ recycle ____________________________________________________________ i've done majority of the coding needed to produce the desired output. however my problem is that i can't get to include the "-a", "-e","-h", options. my code works as it is e.g: if i try an option :-" ./recycle test " (would send the executable file "test" to a folder created called recyclebin. h0wever if i try:- "./recycle -a test" it doesn't work .i created the options "-a", "-e","-h", using a case statement but still no luck. here's my code that works and the code with the case statement that doesn't work: ****************************************************** this one works with out the options #!/bin/sh clear #./home/jjohnson/assignment2/trial #echo $./home/jjohnson/assignment2/trial #./home/jjohnson/assignment2/trial = $./home/jjohnson/assignment2/trial :./trial if [ $# -ne 1 ] then echo " No recycling exist " elif [ -d recyclebin ] then echo "directory exist" mv /assignment2/$1 /recyclebin else echo "No recycling exist " echo " Creating the .recyclebin directory and adding the file now..." mkdir /assignment2/recyclebin mv /assignment2/$1 /assignment2/recyclebin fi #ls -l /recyclebin/ didplays the files and their permissions in the recyclebin #rm * /recyclebin empties all contents from the recycle bin #echo "The recycle bin is empty" ************************************************ this one with options doesn't work #!/bin/sh clear if [ $#- ne 1 ] then echo "No recycling exist " if [ $#- ne 1 ] read option case $option in -a) if [ $#- ne 2 ] then echo "No recycling exist " elif [ -d recyclebin ] then echo "directory exist" mv /assignment2/$1 /assignment2/recyclebin else echo "No recycling exist " echo " Creating the .recyclebin directory and adding the file now..." mkdir /assignment2/recyclebin mv /assignment2/$1 /assignment2/recyclebin fi #mv /assignment2/$1 /assignment2/recyclebin ;; -e) rm * /assignment2/recyclebin echo "The recycle bin is empty" ;; -h) echo "usage " ;; esac ******************************************* please guide me accordingly |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|