The UNIX and Linux Forums  

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
House of Mirrors 0.4 (Default branch) iBot Software Releases - RSS News 0 04-12-2008 02:20 AM
House of Mirrors 0.3.1 (Default branch) iBot Software Releases - RSS News 0 04-04-2008 01:00 PM
House of Mirrors 0.3 (Default branch) iBot Software Releases - RSS News 0 04-03-2008 12:50 PM
Automatic House keeping in UNIX augustinep UNIX for Dummies Questions & Answers 3 11-24-2001 10:42 AM
Help! Newbie in the house!!! The Nutcracker UNIX for Dummies Questions & Answers 4 07-03-2001 02:12 PM

Closed Thread
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
  #1 (permalink)  
Old 12-28-2005
Rakesh Bhat Rakesh Bhat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 8
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


thanks
  #2 (permalink)  
Old 12-28-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 12-28-2005
Rakesh Bhat Rakesh Bhat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 8
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 (permalink)  
Old 12-30-2005
Rakesh Bhat Rakesh Bhat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 8
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 (permalink)  
Old 01-01-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 01-02-2006
Rakesh Bhat Rakesh Bhat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 8
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 (permalink)  
Old 01-02-2006
Rakesh Bhat Rakesh Bhat is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 8
I got the solution , just I forget to put /usr/bin/xargs.

Thanks Blowtrouch,
Closed Thread

Bookmarks

Tags
mtime

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 11:34 PM.


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