Executing Commands In Java

I already know how to execute a system command in Java, but I'm having trouble with a particular multi-line command.

Process p = Runtime.getRuntime().exec("telnet www.nameofsite.com 80");

There is more that follows that command:

The entire command that needs to be executed is:

telnet www.nameOfSite.com 80

GET / HTTP/1.1

User-Agent: Mozilla/4.0

Host:www.nameOfSite.com

Connection:Close

(Press enter key twice at this point)

I store this in one string, called command.

I read the results of the command execution using this:

BufferedReader bf =new BufferedReader(new InputStreamReader(p.getInputStream()));

String temp=new String();

String results=new String();

while( (temp=bf.readLine() ) !=null){

results+=temp;

results+="\n";

}

It returns null every time.

Anyone have any suggestions?

[1219 byte] By [dgriera] at [2007-11-26 12:20:21]
# 1
> Anyone have any suggestions?Use URL, URLConnection and HTTPURLConnection ORopen a Socket to www.nameOfSite.com port 80 and write the data to the output stream and read the result from the input stream.
sabre150a at 2007-7-7 15:10:21 > top of Java-index,Archived Forums,Socket Programming...