preventing "break" in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting preventing "break" in a script
# 1  
Old 04-08-2004
preventing "break" in a script

Not sure if I am using the correct terminology:

I have a user setup in a menu. I want to let the user browse a file using the pg.

I want to prevent the person from doing <ctrl>c and being able to exit the script to the command line.

How do I do this?
# 2  
Old 04-08-2004
man trap.

you can also do a search on this site for that command.
# 3  
Old 04-08-2004
Data

Interesting. No man pages on trap on my servers.
Smilie
# 4  
Old 04-08-2004
syntax
trap "command to run when signal trapped" "list of signals"

trap "" signals # Will trap the signals you define but not allow them to affect your script.

you can get a list of signals by typing kill -l on the command line. Note: You cannot trap signal 9. Your "command to run" can be a function if you so choose.
# 5  
Old 04-08-2004
The syntax depends on your shell. If you are using ksh, you would do a "man ksh".
# 6  
Old 04-08-2004
the man page gives examples for various shells.

Code:
User Commands                                             trap(1)

NAME
     trap, onintr  -  shell  built-in  functions  to  respond  to
     (hardware) signals

SYNOPSIS
  sh
     trap [  argument  n  [ n2 ... ]  ]

  csh
     onintr [ -| label ]

  ksh
     *trap [  arg sig  [  sig2 ...  ]  ]

# 7  
Old 04-08-2004
Yeah, but only Sun has that trap man page. At least it's not on HP. On linux I get a bash man page with "man trap".
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. UNIX for Dummies Questions & Answers

Control-break"ish" in awk

Hi, input: 1|Bob 2|Bob Ref|Bob 3|Rick 7|Rick Ref|Rick I am trying to append a "*" field to the record containing "Ref" in $1, only if the previous $1 with a common $2 have a value <4. ouput: 1|Bob 2|Bob Ref|Bob|* 3|Rick 7|Rick Ref|Rick (11 Replies)
Discussion started by: beca123456
11 Replies

3. UNIX for Dummies Questions & Answers

Find a string across line break (because of "segmentation fault core dumped")

Hi, thanks to a precedent post, and thanks to the reply of derekludwig of the forum, I have convert my first awk command as : test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL awk -f findstring.awk test.txt > textreturn.txtfindstring.awk is : BEGIN{ SLENGTH = 3 } { ... (3 Replies)
Discussion started by: thewizarde6
3 Replies

4. 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

5. AIX

Preventing screen redraw when "more" exits

In previous releases of AIX (<5.3) the "more" command didn't redraw the screen upon exit. This helped when searching in a text document or man page because one could look for the relevant part of it, exit and use the left-over at the screen as reference for typing the next command. Alas, this... (2 Replies)
Discussion started by: bakunin
2 Replies

6. 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

7. Shell Programming and Scripting

"last" in perl vs "break" elsewhere

Is there a functional difference between the two statements? (4 Replies)
Discussion started by: thmnetwork
4 Replies

8. Shell Programming and Scripting

Break line after last "/" if length > X characters

Hello. I am a french newbie in unix shell scripting (sorry if my english speaking is wrong). I have a file with path and filenames in it. I want to limit the number of characters on each line and break the line if necessary. But the "break" should occur after a slash caracter "/". Example of... (9 Replies)
Discussion started by: SportBilly
9 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

10. UNIX for Dummies Questions & Answers

Preventing wildcard expansion in "read"

Hi, I'm trying to use "read" to read in SQL lines and then apply to UDB. However KSH is expanding the *'s in the SQL into a list of all the files in the current directory... Anyway to turn this off? while read SQLStatement do echo "Running : " $SQLStatement... (8 Replies)
Discussion started by: gaijin 06
8 Replies
Login or Register to Ask a Question