Capturing a ^C to break out of a script?
Joel Hammer
Joel
Mon May 17 11:33:55 PDT 2004
I am not sure just what you want to do.
The ctrl-c key should be able to kill your program for you. If not, try
ctrl-\.
Usually, I use the && or || construct if I need to test for the success of a
command before I continue.
eg:
cvs login || exit 1
(I am not sure what cvs login is so this command may not work)
You could also set up a trap, eg:
trap CommandToProcessCntrl-c INT
Joel
On Wed, Jun 26, 2002 at 08:48:03PM +1000, James McDonald wrote:
> Umm I was wondering if there is anyway of breaking out of a script by
> capturing the CTRL+C combination and completey exiting the script I am
> running the following and if the login fails it still trys to go through the
> entire 'for in do'
>
> Thanks
>
> #!/bin/sh
> # login to cvs
>
> me=$0
>
> export CVSROOT=:pserver:guest at cvs.openoffice.org:/cvs
>
>
> cvs login
>
> for i in `echo *`
>
> do
> echo Checking Out $i
> cvs -z3 co -PA $i
> done
>
> cvs logout
>
> echo "$0 Done"
>
> --
> James McDonald
> MCSE (Windows 2000/NT4), CCNA, CCA, MCP + I
> Registered Linux User #209832
> http://jamesmcd.dns2go.com (home)
> Red Hat Linux release 7.2 (Enigma)
> 8:44pm up 11:41, 7 users, load average: 0.28, 0.10, 0.03
>
> _______________________________________________
> Linux-users mailing list - http://linux-sxs.org/mailman/listinfo/linux-users
> Subscribe/Unsubscribe info, Archives,and Digests are located at the above URL.
More information about the Linux-users
mailing list