how to prevent "ctrl-C" input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to prevent "ctrl-C" input
# 1  
Old 01-21-2009
how to prevent "ctrl-C" input

Hi
I have a script and its execution takes 40 - 60 minutes. The script is run on the console window of the machine. Script execution should not be broken by running ctrl-C under any circumstances. Is there a way to lock the window from any user input (ctrl-C in fact) till the end of the script execution. Thanks a lot. -A
# 2  
Old 01-21-2009
# 3  
Old 01-21-2009
One way: block SIGINT with a trap:
Code:
 trap 'echo "you typed ctrl/c"; ' INT
while true
do
 sleep 20
done

PS: if you run this code: you cannot stop it with ctrl/c, you will have to kill it from another process.
# 4  
Old 01-21-2009
Another way.

man stty

For example to turn off interrupt and quit for that session:
stty intr ""
stty quit ""
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Red Hat

"/usr/sbin/hpacucli ctrl all show" command does not work

Dear Concern, We have observed that following command stuck/does not work in some RedHat nodes. Please advise us to troubleshoot the issue. /usr/sbin/hpacucli ctrl all show Note: HP Array Configuration Utility CLI for Linux 64-bit With Best Regards, Md. Abdullah-Al Kauser (3 Replies)
Discussion started by: makauser
3 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Removing "^M" from the end of a String (i.e. "Ctrl+M")?

Hello All, I have an Expect script that ssh's to a remote server and runs some commands before exiting. One of the commands I run is the "hostname" Command. After I run this command I save the output using this line in the code below... Basically it executes the hostname command, then I... (2 Replies)
Discussion started by: mrm5102
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. AIX

AIX - "prevent script from running twice" issue

I know about standard "ps ..|grep .. | grep -v grep" solution, but... this is different issue I have encountered in several companies I worked for. And I see this only for AIX - not HP, not Solaris, not Linux. Korn shell script is scheduled in the background (via cron /via Tivoli Scheduler or... (6 Replies)
Discussion started by: ooops
6 Replies

7. HP-UX

Apache w/ "Coverity Prevent" cannot start... please hellp!

Hi, I am trying to start the apache server on 11i for Coverity Prevent using following command: # cov-start-gui --datadir /qa_home/coverity/data_dir-4.3.0 cov-internal-httpd not running. For further information, see '/qa_home/coverity/data_dir-4.3.0/logs/error_log' # the error_log... (0 Replies)
Discussion started by: prits31
0 Replies

8. Shell Programming and Scripting

How to prevent the pattern "^[[0m" from being written to a file ????

Hi folks, I am using a shell script to display the referred libraries names of any specified cpp code. Given below is the script: shell script "grblib" ------------------------------------------------------------------------- #!/bin/sh # get the lines having "include" pattern ... (5 Replies)
Discussion started by: frozensmilz
5 Replies

9. Shell Programming and Scripting

check input = "empty" and "numeric"

Hi how to check input is "empty" and "numeric" in ksh? e.g: ./myscript.ksh k output show: invalid number input ./myscript.ksh output show: no input ./myscript.ksh 10 output show: input is numeric (6 Replies)
Discussion started by: geoffry
6 Replies

10. Shell Programming and Scripting

sh, ksh: how can i "send" Ctrl+C ?

hi all, hope you can help me with this issue. i'm trying to receive some informations from a website using lynx & sh/ksh. $ lynx http://www.discogs.com/release/392142 | grep "members want" result of this command: 2 members want this <here i have to press Ctrl+C manually to escape, but... (2 Replies)
Discussion started by: pseudocoder
2 Replies
Login or Register to Ask a Question