sort can't stat error.

I am using the command below to sort unique a file and I keep getting this error that sort can't stat.
Error:
sort: can't stat /xxxx/xxxxx/2005/xxxxxx/out_20050602155231/test.txt: No such file or directory

Does anybody have an idea when this error could occur.

Thanks,
Radhika.

if [ ${outfile} = "test.txt" ]
then

#The following command creates the outfile in the outputdirectory.
{SCRIPTSD}/perf_mast.sh ${INPUTD} ${OUTPUTD} ${SCRIPTS} ${filename} ${dm} ${dte}
wait

Command:
#Remove duplicates in the output file and the sorted file name is sort_outfilename
sort -u ${OUTPUTD}/${outfile} > ${OUTPUTD}/sort_${outfile}
wait

make sure you have read permission on the you're trying to sort

Either the file, or in this case more probably the directory you are using in you script doesn't exist.

I am thinking the problem is I am creating the directory on the fly and then the output file on the fly. And I tried to give the read permission on the fly. and then tried sort. It gave me warning: can't access file. Some thing is wrong.

When you are doing sort do we have to be in the directory where the output file exists.

Or can I just give the path to that output file in the sort command?

I have to go pick up my son from daycare and then I will try it again from home!

You can give the path to the file, provided that both the directory and file exist. Really it would be much easier to help if you posted your script. Usually it would not be required to change the permissions on the directory, as it is unusual to use a umask which does not allow the creator to read.

I figured out my problem!!!

I really couldn't have posted the script - it was long and one was calling another too many arguments etc...

Anyway, this is how my code is layed out...

#Main Shell....Script......
doing some processing.....then calls the sub shell script.
First_sub_shell.sh $1 $2 ...
depending on which file and the logic it in turn calls another sub shell script.
Second_sub_shell.sh $1 $2 ....
#Then comes the sort command in the first_sub_shell.
sort -u text.txt > sorted_text.txt

Second_sub-shell script $1 $2.... actually opens a sqlplus session and executes a .sql file to spool data into a text file. Problem was first sub-shell was trying to sort the output text file created in second sub-shell. ONLY, the sql hasn't completed spooling all the data into the text file. I think that's why it couldn't see the text file.

Once I put the wait command in the second sub-shell after the sqlplus call everything works nicely. My sort command is just fine.

I hope you understood-
Thanks for trying.
Radhika.