The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-14-2008
jerryboy78 jerryboy78 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0