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?

