I've written a bash script which captures video with DVgrab. Because of the nature of the tapes that I am digitizing, sometimes I want to quit capturing before the time that I set for DVgrab. When this is the case I press Ctrl-c and DVgrab exits cleanly, my problem is that there is additional information that the script prints in the terminal with 'echo' when the script runs till it's set time. When I Ctrl-c none of this information prints...
Is there a way to intercept the SIGINT ( I think this is what I want, but I could be wrong) and have it operate exactly as it does by default, but additionally echo a few varibles in the terminal?
Preferably I would like to do this just in my script... and not effect the way Ctrl-c functions system wide.
Not sure if it matters, but based on my reading prior to this post I wasn't sure, but I run this script in a virtual terminal in gnome on an Ubuntu (8.10) Linux machine
The bit that I wanted to add when Ctrl-c is pressed looks like this:
Yes, I see that.... I just finished a 2 hr tape and my warning poped up after it ran for the full allotted time and exited normally...
I changed the -2- to -0- just guessing and i thought it was working.... ( I can't for the life of me find a listing of 'trap options' explaining what each number here would do?) I switched it because the -2- option isn't ending the script? It prints my inserted code, but doesn't bring back the prompt, it just continues the script?
---------- Post updated at 04:50 PM ---------- Previous update was at 04:27 PM ----------
Ok, I spoke too soon. the -2- option does stop DVgrab (it doesn't exit the script when i press Ctrl-c before the point in the script when DVgrab starts.... Which is fine except, I also have a function that runs a countdown in my script, and this countdown continues after Ctrl-c... The countdown function looks like this:
Is there something that I could include in my -trap- code that would kill this function and print my warning?
Ok, so I turned my brain on and figured out my solution... I hate it when I catch myself getting lazy on here...
For anyone following the thread, this does what I described needing
Oh, I added the 'sleep' to account for DVgrab's exit info that it prints... otherwise I was getting a few lines printed after the warning...
And I added 'exit' at the end so that the script didn't continue after killing the countdown function
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
The following command will run and wait for input from the user.
/usr/sap/SAP/webdisp/wdispmon pf=/usr/sap/SAP/webdisp/profile
What I would like to do is (in one command):
- Add the above line to a ksh script
- Receive the output
- and send a SIGINT
I have seen many posts on how to... (3 Replies)
Tried to add a function to my control_c interrupt here. It works but has one little bug. If the user selects to run the function instead of exiting, the program restarts itself without forking as it should. However, after that control_c no longer works again. I wanted to allow the user to run... (1 Reply)
Hello,
What I want to accomplish is this:
I have made a very simple script that runs 2 commands, polipo proxy and tor. The script runs successfully and the output of tor is visible to the screen.
I am using the trap command in order to catch the ctrl+c button combo in order to stop polipo... (5 Replies)
Good day,
I am trying to add signal handling capabilities to some of my scripts. Unfortunately, I am having some difficulty with the manner in which signals are propagated between parent/child processes. Consider the following example:
I have the following "parent" script:
#!/usr/bin/sh... (5 Replies)
hi,
in my application, i have set up to capture SIGINT and execute a handler.the problem is whenever i hit C-c, multiple SIGINT are sent to the application.I have blocked the SIGINT right after catching the first one but it is unsuccessful.Here is what i do :
jmp_buf main_loop;
int... (1 Reply)
Hi all,
I have this method to read a string from a STDIN:
void readLine(char* inputBuffer){
fgets (inputBuffer, MAX_LINE, stdin);
fflush(stdin);
/* remove '\n' char from string */
if(strlen(inputBuffer) != 0)
inputBuffer = '\0';
}
All work fine but if i... (1 Reply)
For a program I am designing, which involves handling the keyboard input Ctrl^c (SIGINT), it is taking ages for the program to actually recognise and perform the corresponding action whenever I run it and hit Ctrl^C at the CL. I have to do at least 3 Ctrl^Cs before the program will actually... (3 Replies)