0

here im trying to write shell that will work on specific dates,Sun Solaris 10 does not support new function but im keep getting syntax error near unexpected tokenelif'`

DAY_Word=$(date +%A)

Nomral_Day=$(date +%d)
MONTH=$(date +%m)

if [ "$Nomral_Day" -eq 01 ] || [ "$Nomral_Day" -eq 16 ] && [ "$MONTH" -ne 02 ]
then

###run integrity after

elif [ "$Nomral_Day" -eq 12 ] || [ "$Nomral_Day" -eq 28 ] && [ "$DAY_Word" = "Thursday" ] && [ "$MONTH" -ne 02 ]
then

### run integrity before

elif [ "$Nomral_Day" -eq 13 ] || [ "$Nomral_Day" -eq 29 ] && [ "$DAY_Word" != "Friday" ] && [ "$MONTH" -ne 02 ]
then

### run integrity before

elif [ "$Nomral_Day" -eq 25 ] && [ "$DAY_Word" = "Thursday" ] && [ "$MONTH" -eq 02 ]
then

## run integrity before

elif [ "$Nomral_Day" -eq 26 ] && [ "$DAY_Word" != "Friday" ] && [ "$MONTH" -eq 02 ]
then

## run integrity before

fi
4

You can't omit the command between then and elif. You have to include a command.

Add the command true and your script should work.

  • How would true fix it? – S.S. Anne Sep 8 '19 at 19:53
  • @JL2210 add any command you like. true doesn't do anything, so it's a good choice. – Wildcard Sep 8 '19 at 19:54
  • Ah. I understand. I thought the "can't have no command" was a southern United States thing. See my latest edit. – S.S. Anne Sep 8 '19 at 19:56
  • 4
    Often the command : is used as a placeholder in situations like this. Yes, a single colon is a valid shell command. It does nothing at all, and it's there for situations like this where a command is required by syntax, but you don't want to put any "real" command. – Gordon Davisson Sep 8 '19 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.