Questions tagged [bash-trap]

Use this tag for questions about the `trap` Bash built-in.

171 questions
0
votes
1 answer

Terminate tcpdump in script and continue executing next command

I am trying to create a script in which I have: tcpdump (options) | fgrep (options) > file After I terminate tcpdump with CTRL+C I want these commands to execute: sed (options) file | awk (options) wait rm file The first part is getting done but…
one-liner
  • 791
  • 1
  • 9
  • 19
0
votes
1 answer

Changing parent's trap handler in child bash process

I have a bash function which is invoked as a child process (though backticks) from by bash script. Is there any way to have this function (running in the child process) modify the parent's trap handlers? This function creates a temporary file which…
Taj Morton
  • 1,588
  • 4
  • 18
  • 26
0
votes
2 answers

trap command used to protect a file from Alt + f4

I want to know whether Trap command will be use to protect a file from SIGKILL (ALT+ F4) signal or not. If it is then the following command will does that? trap ~/Desktop/left.py SIGABRT I'm trying to abort the all signals which trying to close…
Prabhu Are
  • 23
  • 6
-1
votes
1 answer

Understanding bash signal handling

Foreword My initial intention was to write a script that keeps checking every 1 second what hardware (maybe sink is a better term?) is playing Spotify music (headphones, stereo,...) such that this information is reliable even after Spotify is…
Enlico
  • 23,259
  • 6
  • 48
  • 102
-1
votes
1 answer

Unable to print last line using awk after using trap in bash script

Bash file is as #!/bin/bash SomeErrorHandler () { (( errcount += $? )) echo -e $errcount } trap SomeErrorHandler ERR uname +a 2>/dev/null uname +a 2>/dev/null uname +a 2>/dev/null uname +a 2>/dev/null uname +a 2>/dev/null uname -a…
lazereyes
  • 107
  • 6
-1
votes
1 answer

Bash-- trap CTRL+C reset terminal properties and end infinite while loop

So I have this infinite loop that changes terminal properties such as foreground/background color. Specifications: When CTRL+C is pressed, before exiting the loop/script it should reset the terminal to original properties. Now I think I need to…
Bruce Strafford
  • 173
  • 4
  • 15
1 2 3
11
12