Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about terminal setting please

Status
Not open for further replies.

hokky

Technical User
Nov 9, 2006
170
AU
Hi Guys,

can you tell me what's wrong with my code
Code:
while :
do
   print
   print " 1) Add users"
   print " 2) Change password"
   print " 3) Logout "
   print

   OLDSTTY=`stty -g`
   stty -icanon min ${MIN} time ${TIME}
   read SEL?" Option: "; RC=$?
   stty "${OLDSTTY}"

   (( RC )) && print "Timed out, exiting" && exit

   case "$SEL" in
      1)   . set_accounts
           ;;
      2)   . newpass
           ;;
      3)   return
           ;;
      *)   print
           print "Invalid Option ${SEL}, please try again!"
           ;;
   esac
   print
done

everytime I typed backspace it generates "^?", how do I change to normal backspace ??

Thanks guys
 
Set the backspace key using

stty erase (hit backspace)

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
How do I put it in a code ?

Any clue ?
 
Hokky,

You can add this into any script.

stty erase <character of your choice>

Alan
 
Control - H for backspace

stty erase ^H

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Anyway, -icanon disables canonical input processing (ie KILL and ERASE)
 
Hi guys,

Sorry, I've tried all of your suggestion and they don't work.

I've tried
stty erase ^H
stty erase ^?

both didnt work

This how I put it
Code:
while :
do
   print
   print " 1) Add users"
   print " 2) Change password"
   print " 3) Logout "
   print

   OLDSTTY=`stty -g`
   stty -icanon min ${MIN} time ${TIME}
   read SEL?" Option: "; RC=$?
[b]stty erase ^H[/b]
   stty "${OLDSTTY}"

   (( RC )) && print "Timed out, exiting" && exit

   case "$SEL" in
      1)   . set_accounts
           ;;
      2)   . newpass
           ;;
      3)   return
           ;;
      *)   print
           print "Invalid Option ${SEL}, please try again!"
           ;;
   esac
   print
done

Any idea ? Thanks guys
 
when you enter the ^H, that is a Control-H not a caret followed by an H.

To enter the Control-H, vi your script. Up near the top go into insert mode and type:

stty erase <control-v><control-h>

<control-v> - hit control and v - you wont see anything on the screen.
<control-h> - right after the <control-v>, type <control-h>. Once you do that, you should see ^H on the screen. Hit escape to get out of insert mode. To verify that you have a <control-h>, use the appropriate vi commands to move the cursor over it - it should jump the ^ and H as 1 character.

You should then be all set for hitting the backspace key.
 
<control-v> - hit control and v - you wont see anything on the screen.
<control-h> - right after the <control-v>, type <control-h>. Once you do that, you should see ^H on the screen. Hit escape to get out of insert mode. To verify that you have a <control-h>, use the appropriate vi commands to move the cursor over it - it should jump the ^ and H as 1 character.

Yes, this is exactly what I did.
 
Did you read the man page and my remark timestamped 2 Apr 07 8:18 ?
 
Anyway, -icanon disables canonical input processing (ie KILL and ERASE)

Oopss.. So that means if I use -icanon I can't erase something ?

There's no key to erase ?
 
Okay, I just need to put the timeout if people didn't input for too long

Can you guys modified my script below :
Code:
read SEL?" Option: "
case "$SEL" in
      1)   . set_accounts
           ;;
      2)   . newpass
           ;;
      3)   return
           ;;
      *)   print
           print "Invalid Option ${SEL}, please try again!"
           ;;
   esac

Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top