Operating System - HP-UX
1833451 Members
3066 Online
110052 Solutions
New Discussion

how can i get this function?

 
thebeatlesguru
Regular Advisor

how can i get this function?

in a shell:
echo "press any key to contiune"

to get it,i write :
read AAA
echo "now contiune"
...

but only when i press enter,it could be contiune,any other key does not work?
what's happen?how can i get the function as the echo says:press any key to contiune....
hihi
4 REPLIES 4
Deepak Extross
Honored Contributor

Re: how can i get this function?

Wouldn't it be easier to change the message to "press Enter to continue" ? :-)
Since 'read' uses buffered input, you have to wait till Enter is hit.
Peter Kloetgen
Esteemed Contributor

Re: how can i get this function?

Hi Guru,

the read-command allways reads from standard input. The input is stopped by the return-key. So it doesn't matter which keys are pressed, the input is ALLWAYS stopped by the return-key.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Robin Wakefield
Honored Contributor

Re: how can i get this function?

Hi,

If you have perl, this should do it:

======================================
#!/opt/perl5/bin/perl
system "stty -icanon";
$key=getc;
system "stty icanon";
print "\n";
======================================

Rgds, Robin.
Carlos Fernandez Riera
Honored Contributor

Re: how can i get this function?

See :

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x96a6ee3e323bd5118fef0090279cd0f9,00.html


But there is another question, i cant find it, that uses a command to do it.
unsupported