Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 03:44 PM
02-13-2006 03:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 03:54 PM
02-13-2006 03:54 PM
Re: trap
Trap command is usually used in shell scripts to trap signals. To know different signal's and its significance try man pag of kill command.
This command command syntax is
trap {commands} {signal number list}
For example let us assume, you shell script creates lot of temp files in the course of execution.When I kill the shell script while it is running using
kill -15 PID, This actually kills the process and exits without any additional execution. Instead you shell scripts sets trap like the folowing..
trap "rm /tmp/tempfile" 15
then the sript will execute the command "rm /tmp/tempfile" when its killed with the signal 15.
I hope this explanation helped,
Regards,
Senthil Kumar .A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 03:54 PM
02-13-2006 03:54 PM
Re: trap
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=30026
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:00 PM
02-13-2006 04:00 PM
Re: trap
Some important signals are,
Signals 1(hangup)
Singnal 2(interrupt)
Singnal 3(quit)
Singnal 0 (shell exit)
Signal 15 (terninate)
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:02 PM
02-13-2006 04:02 PM
Re: trap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:04 PM
02-13-2006 04:04 PM
Re: trap
By giving the follwoing enty in profile.
trap " " 1 2 3
you can "trap"/"supress" those signals.
it means... if the user executes Ctrl+C in a menu, the program won ger terminated and he wont get the shell prompt. Its done for security reasons.
With Regards,
Siva.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:06 PM
02-13-2006 04:06 PM
Re: trap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:28 PM
02-13-2006 04:28 PM
SolutionHi Khashru,
: is equivallent to "" itself....
go thru the follwing,
server[/]#trap
trap -- 'echo '\''logout root'\' EXIT
server[/]#trap : 1 2 3
server[/]#trap
trap -- : QUIT
trap -- : INT
trap -- : HUP
trap -- 'echo '\''logout root'\' EXIT
server[/]#trap "" 4
server[/]#trap
trap -- '' ILL
trap -- : QUIT
trap -- : INT
trap -- : HUP
trap -- 'echo '\''logout root'\' EXIT
With Regards,
Siva.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:29 PM
02-13-2006 04:29 PM
Re: trap
--
trap is using syntax as,
trap "function execution" signal number
trap "" 1 2 3
"" -> Null string .. If it gets the singal then it will do anything.
signal()
{
echo "Got signal"
}
trap "signal" 1 2 3
when ever it gets signal it will call signal shell function.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:30 PM
02-13-2006 04:30 PM
Re: trap
See ksh man page for trap command.
% trap [arg] [sig ...]
arg is a command 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 name of the
signal. Trap commands are executed in signal number
order. Any attempt to set a trap on a signal that was
ignored upon entering the current shell has no effect.
If arg is omitted or is -, all traps for sig are reset
to their original values. If arg is the null string,
this signal is ignored by the shell and by the commands
it invokes. If sig is DEBUG, arg is executed after
each command. If sig is ERR, arg is executed whenever
a command has a non-zero exit code. If sig is 0 or
EXIT and the trap statement is executed inside the body
of a function, the command arg is executed after the
function completes. If sig is 0 or EXIT for a trap set
outside any function, 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.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:32 PM
02-13-2006 04:32 PM
Re: trap
it NOT equivallent.
and setting : dosent trap the signals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:34 PM
02-13-2006 04:34 PM
Re: trap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:35 PM
02-13-2006 04:35 PM
Re: trap
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=943834
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2006 04:40 PM
02-13-2006 04:40 PM
Re: trap
Also, worth reading these pages,
http://unix.ittoolbox.com/groups/technical-functional/hp-ux-l/893492
http://unix.ittoolbox.com/groups/technical-functional/hp-ux-l/893922
-Arun