![]() |
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 |
| 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 |
| Using variables created sequentially in a loop while still inside of the loop [bash] | DeCoTwc | Shell Programming and Scripting | 2 | 06-23-2009 04:59 PM |
| Is there a better way I could have run this loop. (For loop with two variables) | DeCoTwc | Shell Programming and Scripting | 2 | 03-27-2009 02:07 AM |
| while loop inside while loop | panknil | Shell Programming and Scripting | 0 | 01-07-2008 12:49 PM |
| For Loop | knc9233 | UNIX for Dummies Questions & Answers | 6 | 01-12-2007 09:55 PM |
| how to get the similar function in while loop or for loop | trynew | Shell Programming and Scripting | 3 | 06-17-2002 11:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
while loop with 3 ifs
im messing up somehwere...and can't seem to clean up the script...for it to work
objectives: 1. check for today's file, and sleep 30 secs between retries 2. only allow 5 tries before script should fail. 3. if today's file found, wait 30 seconds for it to process.. code: Code:
count=0
while [ $count -lt 5 ]
do
count=`expr $count + 1`
echo "Try $count"
RUNDATE=`date "+%h%e"`
filedate=`ls -l file.xml | awk '{print $6,$7}`
if [ $count -ge 5 ]
echo "Too many retries"
echo "Please check source why the file is not imported"
exit 0
else
if [ "$filedate" = "$RUNDATE" ]
echo "Today's file is ready for processing."
echo "Sleeping 30 secs to allow it to process "
sleep 30
break
fi
fi
if [ "$filedate" != "$RUNDATE" ]
echo "File date in directory is $filedate and today's date is $RUNDATE. They don't match"
echo "Sleeping 30 seconds and trying again; 5 tries is my limit"
sleep 30
fi
done
Last edited by vgersh99; 07-20-2009 at 04:31 PM.. Reason: code tags, PLEASE! |
| Bits Awarded / Charged to sigh2010 for this Post | |||
| Date | User | Comment | Amount |
| 07-20-2009 | vgersh99 | added code tags - charged 3K bits | -3,000 |
|
||||
|
Quote:
$RUNDATE and $filedate will never match here, check why. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|