Computing.Net > Forums > Unix > Auto-Enter ?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Auto-Enter ?

Reply to Message Icon

Name: LANkrypt0
Date: May 20, 2003 at 08:45:24 Pacific
OS: FreeBSD
CPU/Ram: Lots
Comment:

Mind is blanking on this one, but is there a way to have an a "auto-enter" in a read command? I ask because I am revamping an old script I had written for someone, and one of the features is to browse through your contacts. Its is a pain to hit F to go forward and B to go backwards.

Is there anyway for me to just hit F or B (no enter required) to do this?

Thanks in advance.

Written in KSH btw.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 20, 2003 at 14:49:00 Pacific
Reply:

Hi:

There's a way, but you have to mess with the terminal driver:

readkey() {
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 /dev/null
stty $oldstty
}

echo "Press a key"
c=$(readkey)
echo $c

Regards,

Nails


0

Response Number 2
Name: LANkrypt0
Date: May 21, 2003 at 06:03:51 Pacific
Reply:

Im so close I can taste it :)

The whole thing seems to do exactly what I need except for one thing, I get:
dd: unknown operand /dev/null

Any thoughts?


0

Response Number 3
Name: LANkrypt0
Date: May 21, 2003 at 06:07:54 Pacific
Reply:

Forgot to add. If I remove /dev/null I get:
1+0 records in
1+0 records out
1 bytes transferred in 1 secs (1 bytes/sec)

Which is the dd output, and the reason I assume /dev/null was in there.



0

Response Number 4
Name: Nails
Date: May 21, 2003 at 07:29:03 Pacific
Reply:

LAN:

You're looking at the output of the dd command. This forum wipes out the arrow keys upon occasion. redirect the output of the dd command to /dev/null, and it should work.

Sorry about that!

Nails


0

Response Number 5
Name: LANkrypt0
Date: May 21, 2003 at 07:46:04 Pacific
Reply:

No need to be sorry, I figured as much and had tried that previously, but when I do that, I get the same output
1+0 records in
1+0 records out
1 bytes transferred in 1 secs (1 bytes/sec)

but now nothing for c (i.e it doesnt echo)


0

Related Posts

See More



Response Number 6
Name: nails
Date: May 21, 2003 at 14:47:07 Pacific
Reply:

Sorry again. You need to redirect standard error, file handle 2, to /dev/null, so it's

dd bs=1 count=1 2[greater than sign]/dev/null

At that, is obtained by the dd command so it won't echo unless you echo it after the function call.

Regards,


Nails


0

Response Number 7
Name: LANkrypt0
Date: May 22, 2003 at 05:39:06 Pacific
Reply:

I thank you, that worked perfectly.


0

Sponsored Link
Ads by Google
Reply to Message Icon

popassd Solaris 9 AWK program



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Auto-Enter ?

Hangs after entering login www.computing.net/answers/unix/hangs-after-entering-login/3268.html

Auto Kill Unix Process If Idle www.computing.net/answers/unix/auto-kill-unix-process-if-idle/2533.html

cancel the enter key in a text www.computing.net/answers/unix/cancel-the-enter-key-in-a-text-/7344.html