Full Color Command Line Menus


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Full Color Command Line Menus
# 1  
Old 07-27-2013
Full Color Command Line Menus

Hi all,
Did a couple of Google searchs, a couple of searchs on the site here and didn't find an answer... But, maybe I'm not searching for the right phrases.

My question; what creates the full color menus on the command line in unix?

I'm looking for something that would replicate the functionality of a CICS map. Something that would allow multiple input fields to be entered in a shell script menu.
# 2  
Old 07-27-2013
Some theory first:

UNIX is in some ways similar to z/OS and its predecessors. The system has one or several terminals attached over which users can communicate with the main system. The terminals themselves are connected via serial lines.

One big difference is that 3270 terminals have some local intelligence. UNIX terminals are much "dumber" than their mainframe counterparts. They are more similar to printers. Btw.: it doesn't matter if you have a real terminal in front of you or some graphical environment: everything you can type in commands and receive output from the system is either such a serially attached terminal or it is virtualized construct which works exactly the same way. Think of VM/CMS where the CMS machines communicated via virtualized punchers and card readers long after real punchers/readers were used. Same principle here.

Now, all terminals are steered via so-called escape-sequences. These are sequences of characters which all begin with the (unprintable) character for ESC, character number 27. If you want a printer to print part of the text to print in bold you'd embed a steering code into the text on the appropriate position to switch bold printing on, then follows the text you want to have bold, then another code to switch bold printing off, then the remainder of the text. Same principle here: you embed steering codes (all starting with ESC) into the text as you print to the screen.

Problem is now that there are many different terminals and all have different abilities and the different abilities all are steered with different codes. To switch on printing in a VT100 (a very common terminal type) might need other codes than to do the same in a Wyse60 (another common terminal). If you simply put some ESC sequences into your output this might work on the terminal you use, but might fail on the terminal the next one uses.

For this there is a database where all the known terminals and their abilities and the necessary control codes are stored: the termcap (terminal capabilities) database. See the man pages for "termcap" and "stty" for details.

Wich terminal you use, that is: which "main key" the software uses to search in the termcap database for the appropriate entries) is defined by a simple environment variable called "TERM": do an

Code:
echo $TERM

and you will probably see some output. This is the terminal type all the terminal-oriented utilities will use at the moment. You can change this setting at any time but most probably no formatting will work any more from that moment on because all these utlities will use the wrong entry to search the termcap database. Setting it back will correct that again.There is also the "term" command which will (try to) discover which terminal type you are using and produce an appropriate TERM string you can set:

Code:
TERM=$(term) ; export TERM

PS: capabilities of terminals typically include: colours, reverse printing (black on white), cursor positioning, etc. This way you can create menus hich can be controlled by cursor movement.

If you want to do this you might be interested in the "curses"-library, which is designed to put this functionality into a common set of function calls you can use.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 07-27-2013
Thank you, very thorough. Smilie
# 4  
Old 07-27-2013
As an addendum to bakunin's reply take a look at...

ANSI escape code - Wikipedia, the free encyclopedia
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

2. Shell Programming and Scripting

Color line based on first field

Hello, I have a bash script that outputs the following text to a file and then prints that file to the screen: |64 |30 |0 |8 |23:59:14 |38 |57 |2 |14 |00:09:05 |29 |50 |4 |20 |23:58:04 |20 |48 |7 |23 |00:05:44 |18 ... (2 Replies)
Discussion started by: fnj00
2 Replies

3. HP-UX

pgrep doesn't perform full command line pattern matching

Hi! I need to get PID of some particular process and I wonder if I can use pgrep tool for this purpose. The problem is that pgrep doesn't perform pattern matching on the whole command line, even if I use -f key. Parsing output of ps command is not quite convenient... Also deamon, which PID I need... (2 Replies)
Discussion started by: Sapfeer
2 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. Shell Programming and Scripting

.bashrc/PS1 command color different color to command output

I have been configuring my .bashrc PS1 to be displayed with some nice colors and in a format that I like, however there is one thing that I cannot figure out (or know if it's even possible). my PS1 line is as follows: export PS1='\\u\@\\h\:\\w\n\\$ \'This makes the command and command output... (0 Replies)
Discussion started by: jelloir
0 Replies

6. AIX

Getting the process full command line

Hi, I am running java process that has a long command line. Is there a way to get the full command line? By running ps -ef has returns around 2000 chars By running ps eww returns around 2020 chars I am running on AIX 5.3 Thanks, Fredy (0 Replies)
Discussion started by: fredy
0 Replies

7. UNIX for Advanced & Expert Users

Full command line sun 5.10

Hi, I am running on Sun10 platform. I am trying to retrieve the full command line for a process by running ps (/usr/bin/ps or /usr/ucb/ps). Running the "/usr/ucb/ps -agxuwwwww PID" with the user that executed the process i get the full command line. Running the same command with another user on... (4 Replies)
Discussion started by: fredy
4 Replies

8. UNIX for Dummies Questions & Answers

display full unix path as part of the command line

Hi all, Does anyone know how to ammend the .cshrc file in $HOME for your session to display the path as part of the command line? So that I dont need to keep on typing pwd to see where I am? thanks Ocelot (3 Replies)
Discussion started by: ocelot
3 Replies
Login or Register to Ask a Question