Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Ksh Statement with muliple and \or conditions

Posted on 2010-09-13
2
Medium Priority
?
1,113 Views
Last Modified: 2013-12-26
Hi,

I'm trying to write an if statement that has 3 'and' conditions combined with an 'or' for an additional 3 'and' conditions i' have tried a bracketting the statements but either get syntax errors or it hits the first condition and breaks out of the if statement. I've hit a bit of a wall and can't work out what to do nextto make it work. below is the last attempt that failed:

if [ [[ $dbname = PD_EUDW ] && [ $DAY = SAT ] && [ $HOUR > 19 ]] ||
         [[ $dbname = PD_EUDW ] && [ $DAY = SUN ] && [ $HOUR < 20 ]] ]
       then    
              echo $(date +%H:%M:%S) "            " $dbname ":" $Daily ".....Hourly Collection BLACKOUT IN FORCE " >> $LOGFILE
       else
                  echo $(date +%H:%M:%S) "         " $dbname ":" $Hourly ".....Hourly Collection Running " >> $LOGFILE
                  db2 "call perform.$Hourly('$dbname','$DB2DATE')" >> $LOGFILE
fi

0
Comment
Question by:paulpen
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 33660335
if [[  $dbname = PD_EUDW  &&  $DAY = SAT  &&  $HOUR > 19 || $dbname = PD_EUDW  &&  $DAY = SUN  &&  $HOUR < 20 ]]
0
 

Author Closing Comment

by:paulpen
ID: 33660372
quick response - excellent!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question