KSH to determine the day - aix
This is a discussion on KSH to determine the day - aix ; Hello, I'm trying to figure out why this isn't working: DAY=`/usr/bin/date|awk '{print $1}'` if [[ $DAY != "Thur" || $DAY != "Fri"]] then echo "It Works!" fi When I try to run this I get a "`then' is not expected." ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| I'm trying to figure out why this isn't working: DAY=`/usr/bin/date|awk '{print $1}'` if [[ $DAY != "Thur" || $DAY != "Fri"]] then echo "It Works!" fi When I try to run this I get a "`then' is not expected." error. Since today is not Thursday or Friday, I expected this to work. How can I determine when it's not either of 2 days? I have a script which needs to run one thing on Thurs & Fri, but something else every other day. Thanks! |
|
#2
| |||
| |||
|
Pete > Hello, > I'm trying to figure out why this isn't working: > DAY=`/usr/bin/date|awk '{print $1}'` > if [[ $DAY != "Thur" || $DAY != "Fri"]] > then > echo "It Works!" > fi > When I try to run this I get a "`then' is not expected." error. Since > today is not Thursday or Friday, I expected this to work. How can I > determine when it's not either of 2 days? I have a script which needs > to run one thing on Thurs & Fri, but something else every other day. Is this exactly your script? Then it is at least missing a Space before the closing bracket "]]". And Thursday would be output as "Thu" not "Thur" but this would also depend on languange settings. Personally I would use two scripts and start the second one via cron only on thursdays and fridays, which is rather easy to accomplish. Thomas Scheunemann |
|
#3
| |||
| |||
|
On Nov 12, 1:54*pm, Pete > Hello, > > I'm trying to figure out why this isn't working: > > DAY=`/usr/bin/date|awk '{print $1}'` > if [[ $DAY != "Thur" || $DAY != "Fri"]] > then > echo "It Works!" > fi > > When I try to run this I get a "`then' is not expected." error. *Since > today is not Thursday or Friday, I expected this to work. *How can I > determine when it's not either of 2 days? *I have a script which needs > to run one thing on Thurs & Fri, but something else every other day. > > Thanks! Here is a sample of how I would code it. In my example, I used the built-in date functions to look at the day of the week as a value rather than a string. I can in this way set up my script to do something different for EACH day of the week if I wanted. ################## START OF SCRIPT ################## #!/bin/ksh integer DayOfWeek=$(date +"%w") case ${DayOfWeek} in 0|6) { echo "Today is the weekend" };; 1) { echo "I dont like Mondays" };; 2) { echo "Today is Tuesday" };; 3|4) { echo "Today is Wednesday or Thursday" };; 5) { echo "Thank God its Friday!" };; esac ############## END OF SAMPLE ##################### |
|
#4
| |||
| |||
|
On Nov 12, 11:15*am, Thomas Scheunemann > Pete > > Hello, > > I'm trying to figure out why this isn't working: > > DAY=`/usr/bin/date|awk '{print $1}'` > > if [[ $DAY != "Thur" || $DAY != "Fri"]] > > then > > echo "It Works!" > > fi > > When I try to run this I get a "`then' is not expected." error. *Since > > today is not Thursday or Friday, I expected this to work. *How can I > > determine when it's not either of 2 days? *I have a script which needs > > to run one thing on Thurs & Fri, but something else every other day. > > Is this exactly your script? Then it is at least missing a Space before the > closing bracket "]]". And Thursday would be output as "Thu" not "Thur" but > this would also depend on languange settings. > > Personally I would use two scripts and start the second one via cron only > on thursdays and fridays, which is rather easy to accomplish. > > Thomas Scheunemann Yes, this was exactly my script - and you are correct in that I was missing the space. DOH! As for cron, I have this set-up that way temporarily right now. I was trying to keep a cleaner cron by writing a savvy script. This will help me accomplish that.... Thanks! |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 11:50 PM.




Linear Mode