1831645 Members
1879 Online
110029 Solutions
New Discussion

Function Keys in script

 
SOLVED
Go to solution

Function Keys in script

Hi,
I am using HummingBird Exceed xterm. I am using Korn shell, how can I assign Function keys in order to run my assign scripts(Eg. F5 will run abcd.ksh). I don't want to go for emacs. I know I have to add into .profile but how and what value for these function keys. Help or hint will be appreciated.
Thanks
Zafar
Win/Win
4 REPLIES 4
Madhu Sudhan_1
Respected Contributor

Re: Function Keys in script

Good Question. Iam waiting for folks to respond.

Thanks,
Madhu
Think Positive
Bill Hassell
Honored Contributor

Re: Function Keys in script

You could injure your brain by reading the text in:

man terminfo

or use this quick reference guide:

DISCLAIMER: function keys are terminal (or emulator) dependent! That means that if your terminal does not support function keys (aka, programmable keys) then these commands produce a NOP (ie, nothing). To determine if your terminal (based on $TERM) supports these features, use the command:

untic $TERM | grep rmln

as an example to see if rmln works on this terminal (based on the terminfo database stored as binary files in the directory /usr/lib/terminfo/*). For those of you with a true HP smart terminal (262x, 239x, 700/9x) or HP terminal emulator such as hpterm or WRQ's Reflection/1 or Reflection for HP (not to be confused with Reflection/x), QCterm, Minisoft's HP emulator, Attachmate's KEA!, and a few others, these commands will work just fine.

Onward ...

tput smln (turns on the softkey labels)
tput rmln (turns off the softkey labels)

If the above two commands, pop up the softkey labels, proceed...if not, get a smart HP terminal emulator. Here is a link for HP terminal emulators: http://directory.google.com/Top/Computers/Systems/HP_3000/Terminal_Emulators/

They say HP 3000 but they are fine for the HP 9000 and make working with character mode SAM and swinstall MUCH easier.

To load the keys, use the commands in this order:

tput rmln
tput pln 1 "cd /tmp"
tput pfx 1 "cd /tmp"
tput pln 2 "BDF hfs"
tput pfx 2 "/usr/bin/bdf -t hfs"
tput pln 3 "LongList"
tput pfx 3 "/usr/bin/ls -alF"
tput smln

So, to explain the manspeak (language used in man pages), rmln is the code for "Turn off soft labels" and smln is the code to turn on the softkey labels. pln is the command to store text into the softkey label and requires 2 parameters: softkey# "text" (use quotes in case there are imbedded spaces), and pfx programs the softkey# to transmit the string as in:

tput pln 8 "bye bye"
tput pfx 8 "clear;exit"

which programs softkey 8 (usually shows f8 as the label) to display "bye bye", then loads key f8 to transmit clear and exit.

NOTE: Some emulators may not display the new labels unless the display is turned off, so turn off the labels, load the keys and labels, then turn them on as in the example for f1 f2 f3 above.

tput is the most powerful tool there is for handling every terminal WITHOUT using a hardcoded escape sequence. It is impossible to predict what terminal someone is using so by using a terminal ID program (ttytype -s or tset) to set $TERM, then a list of all the supported sequences is immediately available to tput. Standard /etc/profile and .profile will have an automatic terminal ID but is successful only when the terminal or emulator is a Wyse, VT100 or HP style...your mileage may vary.


Bill Hassell, sysadmin
harry d brown jr
Honored Contributor
Solution

Re: Function Keys in script

For exceed, you can modify the codes that are sent from your keyboard, but they will behave that way for every exceed window you have open, therefore if you modify a function key it could disrupt the normal use of such.

How to change a function key (or any key code for that matter):

(01) Start exceed
(02) Right click on the exceed "server" and choose tools->configuration (or xconfig)
(03) From the ?Xconfig? screen, double click on "keyboard input"
(04) From the ?Keyboard Input? screen, in the ?Keyboard Mapping" area, select "edit"
(05) A map of your keyboard will pop up (the XKEYS screen), immediately select file->save as,. and choose an new file name (this prevents you from destroying your keyboard), I added the string "new_" in front of "us.kbf" as in new_us.kbf
(06) From the ?XKEYS? screen Select edit->macros
(07) On the new popup, the ?Macros? screen, select "add"
(08) On the new popup, the "Macro binding" screen, select browse.
(09) On the new popup, the ?Macro Selector? screen, verify that the "macro file" is the new name of your keyboard file (new_us.kbf)
(10) From the ?Macro Selector? screen, select the ?add? key
(11) From the new popup, the ?New Macro Properties? screen, give it a name and a description
(12) Select the ?Start Record? button
(13) Then type in your ?string?, as in /usr/bin/myscript.sh
(14) Select the ?Stop Record? when you are done
(15) Select the ?OK? button
(16) When you are done adding your macro, select the ?OK? button (on the Macro Selector screen)
(17) Now you must ?bind? a function key to your macro, (your macro name should appear in ?grayed out? in the ?selected macro? area) in the bind key area select a function key, like f12 for example
(18) Then change the ?Modifier? from ?none? to ?Control?, this will allow you to use the normal function key, if you don?t change the modifier, then some apps that use this function key will not work any more and will produce undesired results.
(19) From the ?Macro Binding? screen select ?OK?
(20) From the ?Macros? screen, select ?Close?
(21) From the Keyboard map, select file->exit
(22) Save the changes, and make sure they are being saved into your new keyboard mapping file (new_us.kbf)
(23) Close all of your exceed sessions, and exceed itself, or perform a ?exceed server reset? (this will close any open Xsessions).
(24) Give it a try


Live Free or Die

Re: Function Keys in script

Hi,
Thanks to Harry & Bill. Bill I am working on your suggestion also; but the major part is completed thru Harry.
Zafar
Win/Win