1748211 Members
4744 Online
108759 Solutions
New Discussion

Re: Syntex erros

 
Alok_Behria
Advisor

Syntex erros

Hi All,

 

OS :- HPUS 11.11

 

I am using following script to compare dates. While executing , it throwing me following errors, since the script not execcuted fully, I am not sure, weather this is right way to compare dates. Also, not sure about the syntex part.

 

none> ./test.sh
./test.sh[7]: Syntax error at line 7 : `;' is not expected.
oradev3 oraadmin /home/oraadmin/test/dev_monitoring
none> cat -n test.sh
     1  #!/sbin/sh
     2  SID=qfin1
     3  . qa02
     4  typeset -i mHHMM=`date +%H%M`
     5  typeset -i mDD=$(date +%d)
     6  mDay=`date +%a`
     7  if [[ "${mDay}" = "Fri" && ${mHHMM} -gt 1604]]; then
     8  echo "Test succeded"
     9  fi

 

1 REPLY 1
James R. Ferguson
Acclaimed Contributor

Re: Syntex erros

Hi:

 

You need a space character before the closing square brackets on line-7.

 

if [[ "${mDay}" = "Fri" && ${mHHMM} -gt 1604 ]]; then

It's better form to avoid the archaic backtick syntax and use the modern Posix standard of $( ... ).  You did this line line-5.  This improves readability and helps eliminate typos that use a backtick instead of a single quote and vice versa.

 

Regards!

 

...JRF...