954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to execute telnet command in Java

Hi,

I want to check whether a system exists in LAN or not and also the database residing in that system is up or not.So, for this I'm trying to use telnet command as follows,

Runtime rt=Runtime.getRuntime();
Process p=rt.exec("telnet 192.168.1.15");

No error nothing ,It is executing .But by using the above command I don't know how to retrieve the success status .

Please,tell me a solution for this or is there any other way to solve this problem .

Thanks,
Sirisha.

sirishag.ch
Newbie Poster
4 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

I think you will need to use the getInputStream() and getOutputStream() methods in the Process class to be able to do what you want to do. Basically you can use the I/O streams to communicate with the Process and then you can use the output from the Process to work out whether your command is successful. This might require a bit of trial and error, so I'll leave you to have a go at it.

darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
 

We have develop a telnet client and remote server we are facing a problem with telnet command how to execute telnet comand in windows....

Rushikesh27
Newbie Poster
1 post since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You