1833679 Members
4406 Online
110062 Solutions
New Discussion

Re: Shell hpux Question

 
M. FRANGEUL
Advisor

Shell hpux Question

Hello !
How can I quit a loop like "while" simply pushing a keyboard key whith HPUX V11.0 shell ?

Is it possible ? so what is the command ?

Thank's
9 REPLIES 9
Hoefnix
Honored Contributor

Re: Shell hpux Question

If your script is running interactive you can do a .
If it's in the background just kill it.
kill

Regards,

Peter
Bernhard Mueller
Honored Contributor

Re: Shell hpux Question

Hi,

enter stty
and you *should* see that
intr = Contol-C

you may map this differently if you want - at your own risk...

Regards,
Bernhard
Sridhar Bhaskarla
Honored Contributor

Re: Shell hpux Question

Hi,

You can type "ctrl-c" to quit the loop. If it didn't work try "ctrl-\".

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Jeff Schussele
Honored Contributor

Re: Shell hpux Question

Hi,

Besides ^C for interrupt you can try the quit sequence which is typically ctrl-backslash or the kill sequence which is typically ^U
Run
stty -a
to get the mappings for your current term type & session.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Rodney Hills
Honored Contributor

Re: Shell hpux Question

If you want to quite the loop, yet continue with the rest of the script, then use "trap" to catch ctrl-c, set a flag, and test for the flag within your while loop.

HTH

-- Rod Hills
There be dragons...
M. FRANGEUL
Advisor

Re: Shell hpux Question

Thank's Rod,
Excuse me for my english, I'm french
your solution is better for me, but can you please give me an example.

Thank's again.
Rodney Hills
Honored Contributor

Re: Shell hpux Question

Here is an example-

#!/usr/bin/ksh
trap "a=1" 2
a=0
while [[ "$a" = 0 ]] ; do
echo hello
done
echo fini

This will loop echoing "hello" until the ctrl-c is pressed. The trap statement will set a=1 and the while loop will exit.

HTH

-- Rod Hills
There be dragons...
M. FRANGEUL
Advisor

Re: Shell hpux Question

Merci beaucoup Rod.
Rodney Hills
Honored Contributor

Re: Shell hpux Question

If this solution does what you were looking for, then assign points 8-10 to my reply.

This helps other users looking for similar solutions...

-- Rod Hills
There be dragons...