in reply to Return value of telnet using shell scripting

The only way to tell is to scan the output of the telnet command to see if the login succeeded. You have to find something that will be printed when the login is successful but not printed when it isn't. Naturally, this will depend on what system you are accessing.

Also, I would suggest using the Net::Telnet module to programatically exercise telnet.