LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices

Reply
 
LinkBack Search this Thread
Old 12-24-2007, 08:28 AM   #1
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
Red face console text encoding


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.
 
Old 12-24-2007, 09:27 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,388
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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?
--- rod.
 
1 members found this post helpful.
Old 12-24-2007, 10:30 AM   #3
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
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?
 
Old 12-24-2007, 10:38 AM   #4
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Do I need to tweak bashrc to format the encoding of escape characters?
 
Old 12-24-2007, 12:46 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,388
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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?
--- rod.
 
1 members found this post helpful.
Old 12-24-2007, 01:06 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,388
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
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)?
Code:
echo $TERM
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.
--- rod.
 
1 members found this post helpful.
Old 12-25-2007, 02:28 AM   #7
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you Sir. I will find out the detail and come back to you. The machine is not accessible till 27nth. Thanks again for your kind response.
 
Old 01-13-2010, 02:32 AM   #8
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Smile Thank you

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.

Thanks a lot !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
text encoding, emacs and LaTeX. bnj Linux - Newbie 2 10-13-2005 07:56 AM
find out encoding of text kpachopoulos Linux - General 0 08-28-2005 03:03 PM
How do I see all text in console? fannymites Linux - General 2 04-15-2005 06:01 PM
html to text + encoding? David the H. Linux - General 6 11-22-2004 05:10 AM
Console text gamehack Slackware 6 09-25-2004 04:00 AM


All times are GMT -5. The time now is 11:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration