how to execute telnet command in Java

Reply

Join Date: Mar 2008
Posts: 4
Reputation: sirishag.ch is an unknown quantity at this point 
Solved Threads: 0
sirishag.ch sirishag.ch is offline Offline
Newbie Poster

how to execute telnet command in Java

 
0
  #1
Mar 24th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 793
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 110
darkagn's Avatar
darkagn darkagn is offline Offline
Master Poster

Re: how to execute telnet command in Java

 
0
  #2
Mar 24th, 2008
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.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC