I need to open a socket from Java to send my cisco router commands. Since the console Unix command a command as follows:
echo-e "\0root\0cisco-rsh\0help\0"|nc 192.168.1.5 514
The router I returned the information I need.
But if I try to open my Java class from a socket to the port 514 I do so as follows:
String command = "\\0root\\0cisco-rsh\\0help\\0";
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader in = null;
InetAddress direccionLocal = InetAddress.getByName ( "192.168.1.33");
System.out.println ( "Opening Socket");
echoSocket = new Socket ( "192.168.1.5", 514, direccionLocal, 1000);
out = new PrintWriter (echoSocket.getOutputStream (), true);
in = new BufferedReader (new InputStreamReader (echoSocket.getInputStream ()));
) Catch (UnknownHostException e) (
System.err.println ( "Not Found Router");
) Catch (IOException e) (
System.err.println ( "Failed I / O Router");
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
System.out.println ( "Send command ....");
While ((userInput = in.readLine ())! = Null)
System.out.println ( "response:" userInput +);
So I do not get response from my router, which I do not know is that I must send my router when I open the socket.
If someone could help him I would be very grateful.