Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

rsh socket

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");

try (

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");

System.exit (1);

) Catch (IOException e) (

System.err.println ( "Failed I / O Router");

System.exit (1);

)

BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));

String userInput;

System.out.println ( "Send command ....");

out.println (command);

While ((userInput = in.readLine ())! = Null)

(

System.out.println ( "response:" userInput +);

)

Out.close ();

In.close ();

StdIn.close ();

EchoSocket.close ();

)

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.

176
Views
0
Helpful
0
Replies
CreatePlease to create content