I am trying to debug a script. I am getting the error following errors from the code listed below. I am working in Korn shell in a Sun Solaris UNIX environment.
****************
** Error Message **
****************
$ statreports.sh 0030 1327
./statreports.sh[29]: if[2: not found
./statreports.sh[30]: syntax error at line 31 : `then' unexpected
*******************
** Code Causing Error **
*******************
# Check if the second command argument is exists.
if["$#" < 2]
then
((endTime = $startTime + 28800)) # Add 8 hours = 28800 seconds
.
.
.
fi
put a space after the '[' and before the ']'
The error still reads:
./statreports.sh[27]: if[: not found
./statreports.sh[28]: syntax error at line 29 : `then' unexpected
kahuna
September 19, 2007, 3:29pm
4
In addition to the other spaces it needs a space after the "if"
I am trying to debug a script. I am getting the error following errors from the code listed below. I am working in Korn shell in a Sun Solaris UNIX environment.
****************
** Error Message **
****************
$ statreports.sh 0030 1327
./statreports.sh[29]: if[2: not found
./statreports.sh[30]: syntax error at line 31 : `then' unexpected
*******************
** Code Causing Error **
*******************
# Check if the second command argument is exists.
if["$#" < 2]
Commands (e.g., [) and shell keywords (e.g., if) must be surrounded by whitespace:
if [ "$#" < 2 ]
More portable is:
endTime=$(( $startTime + 28800))