Operating System - HP-UX
1833792 Members
2195 Online
110063 Solutions
New Discussion

Re: how to kill script with trap command

 
cybermilky
Occasional Contributor

how to kill script with trap command

Does anyone know how to create a shell script that has endless loop of printing the word "looping" on the screen continuously and cannot be interrupted by Ctrl-C break key. How do I kill the script then?
How do I write this shell script by using 'trap'?
4 REPLIES 4
Christian Gebhardt
Honored Contributor

Re: how to kill script with trap command

Why ?
that sounds like planing a joke
Chris
Chua Wen Ching
Regular Advisor

Re: how to kill script with trap command

I think you only need to specify this code at the beginning of your script.
trap '' 2

2 is meant for interupt or ctrl + c.
wenching
Vincent Stedema
Esteemed Contributor

Re: how to kill script with trap command

Hi,

My guess is that you would be able to kill the script by suspending it (CTRL+Z). Then, find out the job id with the "jobs" command and kill the job using "kill" (e.g. "kill %1" if the job number is 1).

Regards,

Vincent
Paula J Frazer-Campbell
Honored Contributor

Re: how to kill script with trap command

Hi

Please do not use the expertise on the forum to answer your exam or project problems.

We will help if you at least made an attempt and posted your attempt at a script.

But we will not do your project/homework for you.


Paula
If you can spell SysAdmin then you is one - anon