This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to capture diagnostics output continuously

 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Java Specialist,

I would like to write a wrapper/terminal emulator to redirect the continuos
output of a proprietary diagnostic utility, similar to the "top" command in
Unix, where it refreshes it performance detail on the screen.

Let's have a look of the output from "top" on standard output would look like
the following:


This "top" output is being displayed from either an X-Windows/Telnet
emulation(Terminal setting - vt100).

Here is a few lines of code that attempt to capture these data and print it
out through the Netbeans output windows:


Output from Netbeans give:

init:
deps-jar:
compile-single:
run-single:
[0;1H
BUILD SUCCESSFUL (total time: 0 seconds)

As you can see, I have had little success with it so far. The above program
worked for any one off output such as "ls", "ifconfig/ipconfig", etc.

I suspect that there is a way to use Java I/O to buffer these output data and
regularly flushes it out but not sure how to go about getting it done. There
may be 2 approaches to getting the data in, as far as my limited understanding goes:

( i ) regularly abort from running "top" & redirect the output to a file.
( ii ) continuously redirect all the data to a file every time the screen
refreshes.

You may suggest that I should try using certain switches/parameters provided
by possibly "top". Unfortunately, this proprietary primitive diagnostic tool
does not provide such functionality. It only displays the output on the standard
output with the terminal environment variable set to (TERM=Wyse60).

I am fairly new to Java and would appreciate any guidances or different
approaches to achieving the same purpose.

Many thanks,

Henry
 
Joe Ess
Bartender
Pie
Posts: 9265
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has notoriously poor support for the console. Java is intended to be cross-plaform, and there's no telling what the console will be (Windows CMD? Bash? ksh? No console at all (think set-top-box or phone)). You can get some control by using ANSI escape sequences, but you may need to do some work to activate them (and they will not work at all in something like Netbeans).
Speaking of which, try removing the buffered reader, use plain read() and write() and run your app in a native console rather than Netbeans. I'm curious to know if your source application's method of clearing the screen (possibly ANSI control sequences) is propogated to your Java app's console.
 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you very much for your suggestions.

Cheers,

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic