English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hai This is Narendra....
Now I am working on java and my objective is to configure and change the IP addresses of some systems in the network through java code.....

I am unable to telnet to other computer in the network with Runtime.exec() method in java.

How we can resolve this?
How can we telnet to other computer and type some commands like ls or vi and get the output of those commands in our system?
How can we pass some commands as input to that session programatically?

If any reference material is available, please let me know.

Please try to reply me.
I am in urgent need of the solution.

Thanks in Advance
Narendra

2007-10-11 00:27:09 · 4 answers · asked by narendra d 1 in Computers & Internet Programming & Design

4 answers

You're talking about the java equivalent to popen - which is the Process object returned from exec.

E.g.
Process p = Runtime.getRuntime().exec("some command");
InputStream i = p.getInputStream();
OutputStream o = p.getOutputStream();

byte buff[] = new byte[1024];
int n;

n=i.read(buff);
System.out.println(new String(buff,0,n));

o.write( "commands for the exec\n".getBytes() );

etc.

2007-10-18 01:25:29 · answer #1 · answered by Bob R 4 · 0 0

The computer you are aimed at must have a telnet or ftp server running. And you might need to redirect the screen activity.

But you also might want to look at ssh has a replacement for both that supports passed commands and is a little more secure.

2007-10-11 04:51:16 · answer #2 · answered by Gandalf Parker 7 · 0 0

Write a classic java software. type MyClass { public static void major(String... args) { gadget.out.println("this is going to the console"); } } Then (after compiling) run it from the command on the spot with the command: java MyClass undergo in techniques it truly is not java MyClass.type in case you run it with java it may have a console window.

2016-10-09 00:37:01 · answer #3 · answered by Anonymous · 0 0

1. Give the absolute path to your 'telnet' executable.
or

2. You can simulate the needed functionality, see java.net.* URLConnection or just plain Socket.


chec this link along with code willl be helpfull for u hope so

2007-10-11 18:32:54 · answer #4 · answered by rahul 4 · 0 0

fedest.com, questions and answers