How to capture and feed telnet using php and shell scripting?
===

This is what i want to accomplish using php (possibly using exce()?):

1. telnet to a whois registrar using a program called proxychains:

    **proxychains telent whois.someregistrar 43**

2. if failed -> try 1 again
3. feed a domain name to the connection:

    **somedomainname.com**
4. capture data returned by the registrar to php

I have no experience with shell scripting so how do i capture the event 
in which telnet is connected and hangs for input and how do i "feed" it?

Am i totaly off here or is this the right way to go about it? 