The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 01:51 AM
lom don't execute commands pasalagua SUN Solaris 6 01-25-2008 04:22 PM
How to execute multiple commands via ssh srage Shell Programming and Scripting 9 01-05-2008 03:18 AM
Can Xargs execute multiple commands of evry input file nilesrex Shell Programming and Scripting 4 08-30-2006 09:39 AM
how do i get my script to execute multiple commands? hvincent Shell Programming and Scripting 1 04-26-2006 09:19 AM

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 01-05-2009
prismtx prismtx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 24
Execute multiple commands in a find

I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again.

My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit after doing a successful find. It keeps looping and processing until the count is fulfilled. I have tried doing an exit as a -exec on the find as shown below and I have tried checking the status of the find with $?, but it is always "0" whether the file is old or new.

Any ideas?


Code:
typeset -i  count=1

while ((${count} <= 3))
do
 find  /export/home/MYACCT/ -type f -name \ar5.log ! -newer /WORKDIR/REF -exec /export/home/MYACCT/datetest.ksh \; -exec exit 0 \;
   count=${count}+1
   sleep 3600
done

echo "No file to process"
exit 5

  #2 (permalink)  
Old 01-05-2009
Padow Padow is offline
Registered User
  
 

Join Date: Dec 2008
Location: Maryland
Posts: 178
You can try putting the output of the find command into a variable and then checking to see if the variable value is empty or not.
  #3 (permalink)  
Old 01-05-2009
prismtx prismtx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 24
Thanks

Thanks Padow, that worked great.


Code:
abc=`find  /export/home/MYACCT/ -type f -name \ar5.log ! -newer /WORKDIR/REF`

if [ -z "$abc" ]; then
   count=${count}+1
   sleep 3600
else
  /export/home/MYACCT/datetest.ksh
  exit 0
fi
done

echo "No file to process"
exit 5

Closed Thread

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 08:20 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