63 shell scripts Linux learning advanced programming - signal capturing real

First, the exercises

  1, write a script

 

  2, into the circulating loop while

    

 

  3, write a script to achieve:

    a, can detect Class C, Class B, or all the hosts in the network class A is online

      

 

    B, a user is prompted to enter the IP address or network address, which network acquisition, and scans its network segment

Second, signal capture

  1, trap command

    a, listing signal

      (1), trap -l

      (2)、kill -l

      (3)、man 7 signal

    B, the signal is a mechanism for inter-process communications, and a trap command shell process to customize how the captured signals, however, can not trap signal and a capture Tremil KILL signal, i.e., signal 15 and signal 9 as capture signal the purpose is to be defined once the signal arrives we can do what, that can not define its default action, so to imagine if a process can catch the signal KILL, KILL him so no one can say when he kill that invulnerability this is not desirable.

  2, and now we have to write a script to capture the signal

    a, the following script

      

 

    b, above, we express INT signal capture, and then when we execute the ping command script when Ctrl + C interrupt will catch this signal and outputs the echo of contents

      

 

    c, in another form, namely our script to capture the corresponding signal and by our command to deal with the capture of the corresponding event signal how to carry out, such as the following script is the output Quit and exit

      

 

  3, trap usage

    a、trap 'COMMAND' SIGNALS

    b, it often can capture a signal

      HUP, INT

    c, usage examples

      

 

Guess you like

Origin www.cnblogs.com/Presley-lpc/p/12654299.html