1753550 Members
5419 Online
108795 Solutions
New Discussion юеВ

Re: unix command trap

 
Billa-User
Regular Advisor

unix command trap

can somebody help me about the following usage of "trap". i know what "trap" do, but i don't known the usage in the Script below :

"trap ... ; ; trap - 0 1 2 3 15 ; exit 2" 0 1 2 3 15"

what does "trap -" do ?

example of a SHELL Script

test_prozedure()
{

PRID=$$

trap "rm -f /tmp/sh${PRID}.? ; trap - 0 1 2 3 15 ; exit 2" 0 1 2 3 15

sqlplus -s <<-EOF
.
whenever sqlerror exit 9;
whenever oserror exit 9;
.
Commands ....
.
exit 0
EOF

return ${return_cd:-0}

}

test_prozedure
echo $?


best regards Tom
4 REPLIES 4
Rajesh SB
Esteemed Contributor

Re: unix command trap

Hi,

Trap syntax is

trap [arg] [sig]

Where [arg] - command to execute when shell receives listed signals [sig].
YOu can interprest this for your cases.

Regards,
Rajesh SB
James R. Ferguson
Acclaimed Contributor

Re: unix command trap

Hi:

From the 'sh-posix(1)' manpages:

trap [arg] [sig]...

If arg is - (or if arg is omitted and the first sig is numeric), reset all traps for each sig to their original values.

Regards!

...JRF...
Billa-User
Regular Advisor

Re: unix command trap


Thx for your useful answers !

Tom
Billa-User
Regular Advisor

Re: unix command trap

i got a answer to my question