Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am using Upsilon for linux to monitor a UPS. The status is output to the console in a tabular format (voltage , current etc) using control codes. But, in the output I am getting, all text appears continuous, and instead of newline character, I get 79H. For example, it actually wanted to display '230v' under 'voltage', but what gets displayed is voltage79H230V etc. similarly, lot of other characters appear with some numbers. I guess this is because of wrong character sets or encoding for the console. How to set things right? I can see in the software the correct screenshots, but they appear different in my Suse linux.
You are seeing the escape codes used to format the text on the terminal. Assuming that you want to extract the text only, for logging or some other purpose, you will need to find out what kind of terminal is being used, and then you can probably find a reference for the escape character 'language' used by that terminal. From that, you should be able to write a parser in some language such as perl. What are you presently using to capture the output?
Thanks Rod. But then, should I be seeing the escape codes at all, inside the console? Like, if I open word file in word, then I wouldn't see the control codes, but I will be able to see them if I open it in a plain editor. In the same sense, I should see formatted output. Like instead of newline character, I should actually see a newline. Shouldn't I? I am using bash in Suse. Upsilon manual also shows screenshots with formatted text. ie: Text that looks as if it is formatted as a table, sans the lines. Is it because I have not set the encoding properly?
Yes, the concept is similar to the formatting codes embedded in a word processor document. If you look at the file with a different tool, the way it displays the formatting codes will be undefined, since they are intended only for the specific application that created them. Similarly, a console with a terminal emulator will trap the escape codes, and use them to format the text display. Capturing the raw byte stream intended to be parsed by the terminal emulator should result in capturing ALL of the bytes, including the embedded escape sequences. You seem to be expecting the captured byte stream to be correctly displayed on a terminal, when 'replayed'. This is a reasonable expectation, if the terminal matches the type expected by the original application that generated it, and if the tools used to capture and replay the byte stream have not modified it in any way. What tools and methods are you using to perform these actions?
Okay, now I've re-read your original post, and and I think I've misinterpreted your question. If I now understand correctly, you are seeing 'garbage' characters from your application, rather than the nice tabular formatting you expect. The likely cause of this is a mismatch of the terminal emulator that the application expects (should be documented), and the terminal actually being emulated. By default, most Linux consoles will behave much like a DEC VT-100 terminal. The 'TERM' environment variable should reflect this, and ideally, the application using the terminal should use this information to send the correct escape sequences for the terminal in use. What is the value of your present '$TERM' variable (use the actual console window used by your application)?
I am not an expert in configuring linux terminal emulation, and it is a somewhat complex issue with several interracting parts. It would be good to clearly define the problem before proposing any solution.
Got it solved by by configuring the console, but in linux distros, it isn't giving good results. Not sure why. Anyway, I wrote an application from scratch, and used webbrowser to display the results, instead of console.