house keeping script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers house keeping script
# 1  
Old 12-28-2005
house keeping script

Hi,

I am not aware whether any one has posted this early or not.

I am creating a house keeping script in which I give the user two options:

1. creating a zip file.
2. removing all files given by user.

Before taking any action I am asking user to
enter full path of file or files to be removed/zipped.
and File name [any char like file extn , file name , last date modified]

Here is my script:

#!/bin/sh

echo "HOUSE KEEPING"
echo "-------------"
echo "You want:"
echo "1. zip files."
echo "2. remove files."

read option

echo "Enter full File path:"
read PATH
echo "Enter File name:"
read FILE
echo "Enter Date:"
read DAYS


if [ option -eq 1 ]
then
#zip files
/usr/bin/jar -cvf $FILE.jar $PATH

#/usr/bin/find $PATH -type f -name "*$FILE*" -mtime +$DAYS > tmp.txt
fi

if [ option -eq 2 ]
then
#rm files

/usr/bin/find $PATH -type f -name "*$FILE*" -mtime +$DAYS -ls -exec rm -f {} \;

fi

Now the issue is when I select option 1 that is to zip file, I am getting
this error

./House_Keeping2: /usr/bin/jar: not found

I found the path is fine.

could plz help me making this working Smilie


thanks
# 2  
Old 12-28-2005
I think that you are confused with the command that you are using. The options given look very much like the options supplied to tar. Try replacing the '/usr/bin/jar' with '/usr/bin/tar' and see if it works.
# 3  
Old 12-28-2005
thanks,it worked.why I can't I use /usr/bin/jar inside a script.

I wann to delete/tar only files which are in a particular directory and user
will be entering any text of the file.
# 4  
Old 12-30-2005
Quote:
Originally Posted by blowtorch
I think that you are confused with the command that you are using. The options given look very much like the options supplied to tar. Try replacing the '/usr/bin/jar' with '/usr/bin/tar' and see if it works.
Thanks,

can i use zip instead of tar.
like in zip we have option to get list of input files from standard input using:

find . -name "*.[ch]" -print | zip source -@

Can I do the same using tar.

thanks
# 5  
Old 01-01-2006
Quote:
Originally Posted by Rakesh Bhat
Thanks,

can i use zip instead of tar.
like in zip we have option to get list of input files from standard input using:

find . -name "*.[ch]" -print | zip source -@

Can I do the same using tar.

thanks
Sure you can. Just run the command as
Code:
find . -name "*.[ch]" -print | xargs tar -cvf <name_of_output_file>

# 6  
Old 01-02-2006
Hi,

I tried the above command,however I am getting error:

-------------
HOUSE KEEPING
-------------
You want:
1. zip files.
2. remove files.
Enter your option:1
Enter full File path:/home/rb26326/our_scripts/test
Enter File name:.log
Creating zip file
./House_Keeping2: xargs: command not found

Can you let me know what has to been done.

thanks,
# 7  
Old 01-02-2006
I got the solution , just I forget to put /usr/bin/xargs.

Thanks Blowtrouch,
 
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. OS X (Apple)

Apple looking to switch to using in-house ARM chips for their HW.

Hi guys and gals... Intel reportedly expects Apple to start the Mac's transition to ARM next year - 9to5Mac (0 Replies)
Discussion started by: wisecracker
0 Replies

2. Shell Programming and Scripting

In bash script, how to assign output of a command to a variable while keeping tabs?

Hi, wondering if it's been asked before but didn't find matches from google. Basically I have this line: myvar=$(echo -e "a\tb") Now somehow the '\t' from the echo output gets replaced with white space and then stored in $myvar. It creates a problem for me later to use tab as delimiter to do... (2 Replies)
Discussion started by: birddie
2 Replies

3. Shell Programming and Scripting

Mail cleanup from ksh script, keeping 50 most recent msgs

I found some posts describing how to completely clean out a mailbox in Unix/Linux. But I want to keep the 50 most recent messages. Any ideas out there? Thanks! (3 Replies)
Discussion started by: OPTIMUS_prime
3 Replies

4. AIX

Script Keeping Track of Itself

Hi All We have a WEB Based application running on the IBM AIX server. There is a EOD Job which runs a UNIX script containing EOD Jobs. Say If any job fails then we have to explicitly comment out the jobs which were successfully executed and then re run the same. Is there any was by which we... (7 Replies)
Discussion started by: Prashantckc
7 Replies

5. UNIX for Dummies Questions & Answers

Automatic House keeping in UNIX

I have a directory called 'test' which contains many junk files. I want to automate the clean-up task by removing all files which are older than one month. What would be the best option? (3 Replies)
Discussion started by: augustinep
3 Replies

6. UNIX for Dummies Questions & Answers

Help! Newbie in the house!!!

Ok i was reading a book (sad) and it said to type in 'ftp' in Start/Run. I did but I know no commands for it. Can someone help me??? I also typed in 'telnet' and I know no commands for that either so I would like help on that... Thanx ..The Nutcracker Elite.. (4 Replies)
Discussion started by: The Nutcracker
4 Replies
Login or Register to Ask a Question