Capturing a ^C to break out of a script?
Roger Oberholtzer
roger
Mon May 17 11:33:55 PDT 2004
I define a procedure that will be called. In this case, it prints a message
and then calls my Exit procedure for a tidy exit:
#
# Catch program termination.
#
interrupt ()
{
cat <<*EOF*
ERROR: The backup was interrupted before it was complete. This means that you must re-do the backup or risk loosing the files.
*EOF*
Exit ${FAILURE}
}
trap "interrupt" 2 3
On Wed, 26 Jun 2002 20:48:03 +1000
James McDonald <james_mcdonald at bigfoot.com> 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.
--
+============================+===============================+
| Roger Oberholtzer | E-mail: roger at opq.se |
| OPQ Systems AB | WWW: http://www.opq.se/ |
| Erik Dahlbergsgatan 41-43 | Phone: Int + 46 8 314223 |
| 115 32 Stockholm | Mobile: Int + 46 733 621657 |
| Sweden | Fax: Int + 46 8 302602 |
+============================+===============================+
More information about the Linux-users
mailing list