Sponsored Content
Top Forums Shell Programming and Scripting sh: Detect key (CTRL/SHIFT/CAPS LOCK) state? Post 302487543 by methyl on Wednesday 12th of January 2011 08:09:40 PM
Old 01-12-2011
Does "at the keyboard" mean "on the console" ?

This post is very difficult to understand for some reason. Maybe I'm being thick.

Quote:
I'm trying to write a shell script that runs periodically
This implies a regular cron job or some other automated job (hence the reply in post #2). This is clearly? not the case.

Best I can suggest is running the unix command "tty" when "at the keyboard". Hopefully it will reply "/dev/console". If it does, we have a simple way of distingishing where we are.


Btw. It would really help if you answered the questions.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Disabling ctrl-Z key inside shell script

Hi I have tried to disable the CTRL-Z key inside a shell(sh) script using the command trap "`echo "Ctrl-Z key disabled"`" 20But I am not able to exit from the script after pressing CTRL-Z key. How to proceed this? Need reply soon (11 Replies)
Discussion started by: suganthic
11 Replies

2. Shell Programming and Scripting

How to delete ctrl key values in a given string?

Hi all, My query is... in the runtime, you are getting any input string. Unfortunately, you have pressed some ctrl keys or esc keys or arrow keys while typing input string. You can get the input value like that... input string as welcome^ So ,I want to remove those unwanted keys... (4 Replies)
Discussion started by: balan_mca
4 Replies

3. Red Hat

Caps lock dtterm

Hello, We are having a problem with running dtterm off a RHEL server. Logging into an HP-UX server from a RHEL 5.1 desktop, setting DISPLAY and running dtterm, the caps lock does not work. We have been playing with xmodmap & stty but to no avail. Any help appreciated. mgb (1 Reply)
Discussion started by: mgb
1 Replies

4. HP-UX

Caps lock dtterm

Hello, We are having a problem with running dtterm off a RHEL server. Logging into an HP-UX server from a RHEL 5.1 desktop, setting DISPLAY and running dtterm, the caps lock does not work. We have been playing with xmodmap & stty but to no avail. Any help appreciated. mgb (7 Replies)
Discussion started by: mgb
7 Replies

5. Shell Programming and Scripting

How to issue ctrl+D and enter key

My problem is that i have to connect Linux server. I can connect it with SSH but because of the software of the Linux server, i need to press enter and after ctrl+D. Therefore, I need to write a script that should press enter and ctrl+D. How can i write it in KSH shell script. HELP ME! (7 Replies)
Discussion started by: fozay
7 Replies

6. UNIX for Advanced & Expert Users

Set Caps and Num lock from within X?

Hello, Not sure if this is the right place to post it but.. I have a requirement to set Caps lock and/or Num lock on and off via a Cron job. Now I have working scripts that do the job, but as soon as X starts up the jobs no longer run (well they appear to, but Caps lock and Num lock do not... (0 Replies)
Discussion started by: autotuner
0 Replies

7. UNIX for Dummies Questions & Answers

Caps lock problem

hi all this s quite a foolish problem. I seem to hav pressed some keys s.t in unix, my letters are comin in caps and with caps lock on, i am getting lowercase letters. :o Pls help. Also is there any reference or manual where i can check in case such problems arrise? thanx in advance curiosity (4 Replies)
Discussion started by: curiosity
4 Replies

8. Shell Programming and Scripting

How to detect key press in cgi shell script?

I want to detect key pressed in my .cgi web page, but it does not work even I found the code in other web site. My code is : #!/bin/sh #================================================= # PATH defination # ================================================... (2 Replies)
Discussion started by: Shuinvy
2 Replies

9. Shell Programming and Scripting

Generate all possible word with caps and no caps

With use of sed/awk, how can I print all possible combinations of a word with caps/non-caps. Eg Applying operation on "cap" should generate output as follows. cap CAP Cap cAp caP CAp cAP CaP (12 Replies)
Discussion started by: anil510
12 Replies
KEYMAP(5)							File Formats Manual							 KEYMAP(5)

NAME
keymap - keyboard maps SYNOPSIS
/etc/keymap DESCRIPTION
/etc/keymap is the compressed mapping from keyboard scan codes to ASCII. It is made from a keymap source file consisting of MAP_COLS col- umns (MINIX assigns the value 6 to MAX_COLS, corresponding to key pressed, key+SHIFT, key+LEFT_ALT, key+RIGHT_ALT, key+ALT+SHIFT and key+CTRL) and NR_SCAN_CODES rows (MINIX assigns the value 0x80 to NR_SCAN_CODES, corresponding to the number of scan codes to be provided by the keyboard), and each element is 2 bytes in length (see u16_t in type definitions). The low order byte corresponds to the character represented by the scan code, and the high order byte corresponds to the special meaning (when CAPS LOCK has effect, if it is a function key, etc.), which is converted to binary keymap format using the genmap utility. Types (general): <sys/types.h> <sys/types.h> defines the u8_t and u16_t types, corresponding to 8 and 16 bit values. Macros: <minix/keymap.h> C(c) - Control Maps to control code A(c) - Alt Sets the eight bit CA(c) - Control-Alt Short for A(C(c)) L(c) - Caps Lock Adds Caps Lock effect These macros are used in a keymap source file to help define keys. So instead of writing 032 to put a CTRL-Z in the map you write C('Z'). The L(c) macro is used in column 0 to tell that the Caps Lock key is active for this key. (Caps Lock should only have effect on letters.) Definitions: <minix/keymap.h> <minix/keymap.h> contains a large number of definitions for special keys, like function keys, and keys on the numeric keypad. They are: Escape key and modifiers: EXT, CTRL, SHIFT, ALT. Numeric keypad keys: HOME, END, UP, DOWN, LEFT, RIGHT, PGUP, PGDN, MID (numeric '5'), PLUS, INSRT. ALT + numpad key: AHOME, AEND, ..., AINSRT. CTRL + numpad: CHOME, CEND, ..., CINSRT. Lock keys: CALOCK (Caps Lock), NLOCK (Num Lock), SLOCK (Scroll Lock). Function keys: F1, ..., F12. ALT - function key: AF1, ..., AF12. CTRL - function key: CF1, ..., CF12. SHIFT - function key: SF1, ..., SF12. ALT - SHIFT - function key: ASF1, ..., ASF12. There is one key definition that isn't a key at all: EXTKEY. This keycode is sent by the keyboard as an indicator that the next keycode is special. For instance both ALT keys have the same keycode, but the right ALT key is sent by the keyboard preceded by the EXTKEY keycode. The same is true for the '/' key on the numeric pad versus the other '/' key on the US keyboard. (On other keyboards this key may have a different symbol.) The keyboard driver knows that a different key is presses if it is preceded by EXTKEY. Creating/changing keyboard mapping You can create your own keyboard mapping by copying one of the existing keymap source files (Standard Minix: kernel/keymaps/*.src, Minix- vmd: kernel/ibm/keymaps/*.src) and modifying the desired keys. Once this has been done, you need to recompile the genmap.c file, either by adding a new entry to the Makefile, or by running the following commands: cc -DKEYSRC="keymap.src" genmap.c After this, the keymap file can be generated by running: a.out > keymap.map The keymap can be loaded in the keyboard driver by: loadkeys keymap.map It is wise to first run loadkeys on one of the maps in /usr/lib/keymaps so that you can easily revert back to a known keymap with a few taps on the up-arrow key and pressing return. You will otherwise have to fix the keymap with a faulty keymap loaded into the keyboard driver, which is no fun. When the keymap is to your satisfaction you can copy it to /etc/keymap to have it loaded automatically at reboot. FILES
/etc/keymap Default keymap file SEE ALSO
loadkeys (1). AUTHOR
Victor A. Rodriguez - El bit Fantasma (Bit-Man@Tasa.Com.AR) KEYMAP(5)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy