11-28-2008
trap sig_handler 15
or trap sig_handler SIGTERM
10 More Discussions You Might Find Interesting
1. AIX
I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies
2. Shell Programming and Scripting
Hi
I have tried to disable the CTRL-Z key inside a shell(sh) script using the command trap "`echo "Ctrl-Z key disabled"`" 20But I am not able to exit from the script after pressing CTRL-Z key.
How to proceed this? Need reply soon (11 Replies)
Discussion started by: suganthic
11 Replies
3. Shell Programming and Scripting
I am trying to trap CTRL-C, now the program I call has it's own exit message, I think this is the problem ..
This is what I have now :
function dothis
{
echo 'you hit control-c'
exit
}
function settrap
{
trap dothis SIGINT
}
settrap
until false; do
./ITGRecv.exe
doneDoing this I... (2 Replies)
Discussion started by: Pmarcoen
2 Replies
4. Shell Programming and Scripting
Hello,
I have a script which copies via scp several large files to a remote server. What I want is that even if someone hits CTRL-C, the scp commands continues till the end.
Here is what I wrote
#! /bin/bash
function testFunction
{
echo "COPY START"
scp large.tar.gz... (11 Replies)
Discussion started by: RobertFord
11 Replies
5. Shell Programming and Scripting
Hi ,
i have a scenario where...i have to put a check where if script is executing more than 15mins i have to kill that script and n retry again 2nd time.
i this case i can use background process to do it but i feel trap will be the efficent way to do so...
but i dont know much about it... (1 Reply)
Discussion started by: crackthehit007
1 Replies
6. Shell Programming and Scripting
Hi All,
I would like to write a shell script to find Control M charactes and after getting the result i want to delete it. But in the script the following command couldn't work.
find . -exec grep -l '^M' {} \; > test.txt
^M is ctrl V and M
thanks in advance for any help. (4 Replies)
Discussion started by: jatanig
4 Replies
7. Shell Programming and Scripting
Hi All,
Although each line below seems to work by itself, I've been having trouble getting the Control-C trap working when I add the "|perl -pe..." to the end of the tail -f line, below.
(That |perl -pe statement basically just adds color to highlight the word "ERROR" while tailing a log... (2 Replies)
Discussion started by: chatguy
2 Replies
8. Shell Programming and Scripting
Hi,
while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder.
How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies
9. Shell Programming and Scripting
The below script has Perl script in it where it gives the usage details.
filer.sh
echo
echo -en "Enter filer : "
read filer
echo "test.pl -f $filer -F L"
Output
=========
The following hosts are online and available:
Name Total Allocated Used ... (2 Replies)
Discussion started by: nareshkumar522
2 Replies
10. Shell Programming and Scripting
Hello:
Am trying to understand why the method #2 works but method #1 does not.
For both methods, sending CTRL+C should kill both the Parent script & all of the spanwd background procs.
Method #1:
==========================
#!/bin/sh
ctrl_c()
{
echo "** Trapped CTRL-C"
... (3 Replies)
Discussion started by: gilgamesh
3 Replies
trap(1) 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...]]
DESCRIPTION
sh
The trap command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n). (Note: argument is scanned
once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number or corresponding symbolic
names. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11
(memory fault) produces an error. If argument is absent all trap(s) n are reset to their original values. If argument is the null string
this signal is ignored by the shell and by the commands it invokes. If n is 0 the command argument is executed on exit from the shell. The
trap command with no arguments prints a list of commands associated with each signal number.
csh
onintr controls the action of the shell on interrupts. With no arguments, onintr restores the default action of the shell on interrupts.
(The shell terminates shell scripts and returns to the terminal command input level). With the - argument, the shell ignores all inter-
rupts. With a label argument, the shell executes a goto label when an interrupt is received or a child process terminates because it was
interrupted.
ksh
trap uses arg as a command to be read and executed when the shell receives signal(s) sig. (Note that arg is scanned once when the trap is
set and once when the trap is taken.) Each sig can be given as a number or as the name of the signal. trap commands are executed in order
of signal number. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. If arg is omitted
or is -, then the trap(s) for each sig are reset to their original values. If arg is the null (the empty string, e.g., "" ) string then
this signal is ignored by the shell and by the commands it invokes. If sig is ERR then arg will be executed whenever a command has a non-
zero exit status. If sig is DEBUG then arg will be executed after each command. If sig is 0 or EXIT for a trap set outside any function
then the command arg is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each
signal number.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), exit(1), ksh(1), sh(1), attributes(5)
SunOS 5.10 23 Oct 1994 trap(1)