Clues:
a) If you are in batch mode, do you need a TERM variable to be set?
b) what is a script ( batch or interactive) ?
Who would want to use telnet like that anyway? knowing the next thing will be login prompt and you cannot interact..
If that is what you want then look at expect (you will need to download it...)