I've tried it as one string and haven't gotten it to work. It's a fake http server that our professor set up for class. I'm trying to connect on a port thats open, just to see if it lets me. I'll take any output at all, I just want to see something printed in the console.
Code:
try
{
// Execute a command with an argument
String result = "";
String[] commands = new String[]{"/bin/nc.traditional", "www.mywebserver.com", "20000","-v","-v"};
//String command = "nc www.mywebserver.com 20000 -v -v";
Process child = Runtime.getRuntime().exec(commands);
BufferedReader input = new BufferedReader(new InputStreamReader(child.getInputStream()));
while ((result = input.readLine()) != null)
{
System.out.println(result);
}
input.close();
}