A: 

$TRACES/batch/$Mil.$batch.log is becoming /batch/20100319160018.afce01aa.cr.log so I guess $TRACES isn't defined.

I guess the /batch directory doesn't exist.

Douglas Leeder
$TRACE is an environment variable and is defined./batch directory was created manually before the execution of this batch.:(Thx anyway.
Mat
TRACE != TRACES
Douglas Leeder
+2  A: 

you should define your TRACES variable. Also, use $() instead of backticks whenever possible.

TRACES="something here"
Mil=$(date +"%Y%m%d%H%M%S")
batch="${DatMusic}"
TabimportEnteteMusic="importentetemusic.dat"
{
    grep '^ENTETE' "${IMPORT}/${DatMusic}" > "${IMPORT}/$TabimportEnteteMusic"
    mysql -u basemine --password="basemine" -D basemine -e "delete from importmusic;"
    mysql -u basemine --password="basemine" -D basemine -e "delete from importentetemusic;"
} >> $TRACES/batch/${Mil}.${batch}.log 2>&1
ghostdog74
Thx but $TRACE is an environment variable and it exists.:(
Mat
@Mat, `$TRACE` or `$TRACES` ?
glenn jackman
Yes Thx for all. It was MY mistake, mea culpa... My error was that TRACE was defined but not TRACES, and I'm using TRACES in my script. Sorry for my answers, I was persuaded to make well. Thx again to you all..... and sorry for my english written ;)Have a good day!
Mat
+1  A: 

The error message speaks about the /batch/20100319160018.afce01aa.cr.log file.

This means that $TRACES/batch/${Mil}.${batch}.log is replaced by /batch/20100319160018.afce01aa.cr.log

This means that the $TRACES variable can't be defined at the place you are using it (event if you repeat one hundred times "$TRACE is an environment variable and is defined").

Try a

echo "\$TRACES $TRACES"
jag