Apache Commons telnet connection with a continuous command
Hi all.
Im currently trying to write an application that connects to a telnet server and tails a log file. What I hope to achieve is to check new data as it arrives, record timings of various jobs and play an audible alert when certain phrases are picked up in the file. I have created a telnet class to send and receive data using the Apache Commons libraries, this class works perfectly. I am able to use the application as an interface to the server, send commands and display the output. The problem I am having is that when the tail -f command is issued, it never gets to the end of the output so the method never returns control to the main class. If a command like 'ls' is issued there is no problems. I have a suspicion that the answer may be to use threads and have the command run in a seperate thread which can be killed when desired, but I know very little about threads. Does this seem a reasonable approach? What I would really like if possible is a way of doing essentially the following: Code:
while (connected) I have seen an SSH/Telnet class that seems to have a method that does essentially this (I believe it's a commercial offering by JScape), but the budget for this project is 0 and they want $599 for licencing. If anyone has any advice on this then I would be grateful. Thanks, Chris |
Can you post some code and show which method is not returning? I assume you are using org.apache.commons.net.telnet?
|
The method that is being used to send the command is:
Code:
public String sendCommand(String command) [CODE] public void write(String value) { try { out.println(value); out.flush(); } catch (Exception e) { e.printStackTrace(); } } [/CODE} Which is called by: Code:
aOpenConnection = new AbstractAction("Open Connection") |
All times are GMT -5. The time now is 02:05 AM. |