The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Func 0.16 (Default branch) iBot Software Releases - RSS News 0 02-06-2008 09:30 PM
FLOOR Func user_prady Shell Programming and Scripting 1 10-17-2007 03:16 AM
difference between int ** func() and int *& func() devesh High Level Programming 1 12-05-2005 11:34 AM
command utilizing high CPU azmanw2004 Shell Programming and Scripting 6 06-07-2005 06:26 AM
arrow keys / special keys raguramtgr UNIX for Dummies Questions & Answers 3 02-19-2004 11:45 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-22-2005
Registered User
 

Join Date: Dec 2005
Posts: 2
Talking Utilizing func keys in scripts

I would like to have the function keys available to me in my scripts. Anyone have any ideas on how to map these to functionality I design?
Reply With Quote
Forum Sponsor
  #2  
Old 12-22-2005
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
Hi,
Well after some research this is what i can say.
I use k-shell. on the prompt, if I press the ctrl-v and then the F1 key, i see the characters ^[OP. these are 3 characters. So I wrote a small function getch as follows

function getch {
stty raw
typeset x
x=`dd bs=1 count=3`
stty -raw
echo $x
}

So when I have to check for say F1 in a script I use it as
keyPressed=`getch`
if [ "${keyPressed}" = "^[OP" ]; then
## the ^[OP is not those characters, but it is 3 characters that i get after typing ctrl-v followed by F1
echo " You typed F1"
fi

Hope this helps.
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #3  
Old 12-22-2005
Registered User
 

Join Date: Dec 2005
Posts: 2
hmmm...

First off, thank you for your effort it is much appreciated. Secondly, can you explain each step in you getcha function.
Reply With Quote
  #4  
Old 12-22-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Hmm.

The stty command allows you to map control keys to tty functions like erase
Code:
 stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^z" kill "^o"
This example sets ^C (control/c) to intr (interrupt), backspace ^h to erase....and so on.

Some terminal emulators allow you to map functions keys to actual UNIX commands,
but this is not specific to UNIX itself. An example is secureCRT from Vandyke Technologies.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0