- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- trap question
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
Discussions
Discussions
Forums
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
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
тАО01-12-2005 08:30 PM
тАО01-12-2005 08:30 PM
trap question
i read about it .but i coudn't use it
can any one help me?
i want an example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:35 PM
тАО01-12-2005 08:35 PM
Re: trap question
trap is a shell command to ignore certain signals like ^C or hangup. See the manual page of the shell you are using. It is used like
trap 1 2 15 ""
You specify the signals you want to catch and the action that is to be taken when a signal occurs.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:48 PM
тАО01-12-2005 08:48 PM
Re: trap question
but i don't understand how can i receive the
output from trap?
EX:
****
if i want to execute a sample shell
and i want to receive a signals explane the status.
what command can i write to do that
NOTE:
i have hp-ux V.10
when i type
man trap
no manual entry
thanx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:50 PM
тАО01-12-2005 08:50 PM
Re: trap question
e.g.
trap 15 "echo \"Hello\""
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:53 PM
тАО01-12-2005 08:53 PM
Re: trap question
# kill -l
it will show you the names of the signals and their numeric values. e.g.
15 = TERM or SIGTERM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 10:36 PM
тАО01-12-2005 10:36 PM
Re: trap question
Processes may be sent signals using either the kill command, or a control key combination such as CTRL-C.
The trap command typically appears as one of the first lines in the shell script. It contains the commands to be executed when a signal is detected as well as what signals to trap.
#!/bin/sh
TMPFILE=/usr/tmp/junk.$$
trap 'rm -f $TMPFILE; exit 0' 1 2 15
.
.
.
Upon receiving signals 1, 2 or 15, $TMPFILE would be deleted and the script would terminate the shell script normally. This shows how trap may be used to clean up before exiting.
#!/bin/sh
TMPFILE=/usr/tmp/junk.$$
trap '' 0 1 2
.
.
.
The above example shows how trap may be used to ignore specific signals (0, 1 and 2).
NOTE that when the signal is received, the command currently being executed is interrupted, and execution flow continues at the next line of the script.
Hope this helps
--
M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2005 07:21 PM
тАО01-13-2005 07:21 PM
Re: trap question
For future reference.
The command "man sh-posix" would be a good place to look for infomation regarding built in shell commands.
Regards
Gerhard