how to rename a file before and after a ftp?

I doin a script in sh.
For example:
i have this code here whereby $5 is a text file. eg file.txt. I wanna rename it to file.txt.tmp. so i use this code below which is correct.
put $5 $5.tmp

But when the ftp transfer is complete i need to rename the file back to $5 which is file.txt.

How do i do that?
izzit use
mv $5.tmp $5?
i got problem with that...

Thanks in advance for those who help.

Could you post the script you are using so i can get a better understanding what you are doing ?

use the ftp `rename` command