cant get the right exit message

#!/bin/ksh
application task run command //returns 0 if successful
if [$? eq 0]; then echo "Ran Fine"
else echo "Didnt run"
fi

When I run the script, here is the output
Status code = 0
ksh: [0: not found.
Job didnt run

any suggestions?


pwd
if [ $? -eq 0 ]; then echo "Ran Fine"
else echo "Didnt run"
fi

I still get the same error. Why do we need to put hyphen infront of operator?

script executed
#!/bin/ksh
application task run command //returns 0 if successful
if [$? -eq 0]; then echo "Ran Fine"
else echo "Didnt run"
fi

ouput:
Status code = 0
ksh: [0: not found.
Didnt run

You are missing spaces after the "[" and preceeding the "]". This is the required syntax.

Please look carefully at the previous response.

if [ $? -eq 0 ]; then echo "Ran Fine"
else echo "Didnt run"
fi

You'll have to ask the folks who designed the shell on this question. It's just simply required.

Thomas

Thanks Guys :slight_smile:

hyphen was needed before 'eq' since the operands were numericals