Note that sending the information to the telnet session and parsing the return information from there is best done by using Expect - it is meant precisely for communicating automatically with ostensibly interactive interfaces.
Comment on Re: Re: Passing client information between multiple sockets...