Utilizing func keys in scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Utilizing func keys in scripts
# 1  
Old 12-22-2005
Computer 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? Smilie
# 2  
Old 12-22-2005
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.
# 3  
Old 12-22-2005
hmmm...

First off, thank you for your effort it is much appreciated. Secondly, can you explain each step in you getcha function.
# 4  
Old 12-22-2005
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

NFSd command utilizing more cpu

Hi, I see following 'nfsd' command is using more CPU. Could someone please comment on it's pros and cons of it? CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND 5 ? 16890 root 152 20 34696K 12036K run 57166:48 856.13 854.64 nfsd OS -- HP-UX One... (4 Replies)
Discussion started by: Maddy123
4 Replies

2. Homework & Coursework Questions

Utilizing the Make Command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: ]Compile cpp2html.c to produce cpp2html.o. ( Important: the source code in these files is C, not C++, and so... (1 Reply)
Discussion started by: bgnaranjo1
1 Replies

3. Homework & Coursework Questions

Utilizing the Make Command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Compile cpp2html.c to produce cpp2html.o. ( Important: the source code in these files is C, not C++, and so... (8 Replies)
Discussion started by: lamentofking
8 Replies

4. Solaris

Ram not utilizing

We are using oracle database on solaris 10 sparc 64 bit on M5000 machine. we facing performance related issues. We diagnose using prstat -a command that oracle user not utilizing the ram more than 30 gb total we have 64 gb ram available as in project max-shm-memory set to 42 gb . We are running... (2 Replies)
Discussion started by: zeeshan047
2 Replies

5. UNIX for Dummies Questions & Answers

Unknown process utilizing CPU.

Hi i recently observed my cpu being used 100% due to which load average on machine get increased to < 5. I have no idea what the process is? Appreciate any help in this regard. root 15859 99.9 0.0 5668 1592 pts/4 R+ 12:28 660:06 \_ pvs root 7334 99.9 ... (2 Replies)
Discussion started by: pinga123
2 Replies

6. Shell Programming and Scripting

Utilizing libraries when you aren't root.

I'm having a bit of trouble trying to make use of Net::SSH::Expect. I've started getting dependent libraries and set PERL5LIB to add my custom path because I don't have root access. I tried using cpan, but it always tries to use paths I don't have access to. Next, I tried just moving the .pm... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. Shell Programming and Scripting

Using arrow keys in shell scripts

I recently needed to collect arrow keys (and function keys etc.) in a shell script so that I could run a text graphics-style data entry system (with text entry fields, drop-down list boxes, progress bars and the like). Yes you can do all this in shell, and portably too if you're careful. I've... (4 Replies)
Discussion started by: cambridge
4 Replies

8. Programming

difference between int ** func() and int *& func()

What is the difference between int** func() and int*& func(). Can you please explain it with suitable example. Thanks, Devesh. (1 Reply)
Discussion started by: devesh
1 Replies

9. Shell Programming and Scripting

command utilizing high CPU

Can anybody please help me on how to optimize following command as it use up a lot of CPU : tail -f $DIR3$DATE4.log |\ while read line do echo $line | egrep "Processing incoming SMS message" | sed 's/\,/ /g' \ | awk '{print $2}' >> $DIR2/LIST1.$DATE4.log && echo... (6 Replies)
Discussion started by: azmanw2004
6 Replies

10. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies
Login or Register to Ask a Question