printf command

I want to make a logfile with error messages, like this:
(collumms: CUSTNR DATE TIME ERROR MESSAGE)

 
102      20020807 135417 1 Uptime server is more than 6 months
5        20020808 111335 3 Backup not Ok!
2001     20020808 120428 6 Free space at server1 is less than 20%
etcetera

I made this script:

CUSTNR=101
DATE=`date +%Y%m%d`
TIME=`date +%H%M%S` 
ERROR=1
MESSAGE="Uptime server is more than 6 months"

printf "%-8s %-10s %-6s %-6s %-80s\n" $CUSTNR $DATE $TIME $ERROR $MESSAGE >> error.log

But the variabele MESSAGE is printed wrong. The logfile looks something likes this:

 
102      20020807 135417 1 Uptime 
server   is       more   than 6 months

One of the problems are the spaces between de words in the MESSAGE strings.
How can I solve this/these problems?

Try adding the line:

 IFS=""

to your script. This will reset the International Field Seperator such that it will no longer include blanks. I tried this here and it worked fine.

I found the solution.

I have replaced $MESSAGE by "$MESSAGE".

printf "%-8s %-10s %-6s %-6s %-80s\n" $CUSTNR $DATE $TIME $ERROR "$MESSAGE" >> error.log