- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need Syntax and Manual for trap command
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
тАО05-19-2003 07:50 PM
тАО05-19-2003 07:50 PM
Need Syntax and Manual for trap command
There is no man page for trap command.
But in our scripts, trap command is
being used in many places.
To understand these funcions, I need the
full syntax and use of this command.
Thanks
R.Ezhil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2003 07:53 PM
тАО05-19-2003 07:53 PM
Re: Need Syntax and Manual for trap command
Try this...
http://www.docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90046/B2355-90046_top.html&con=/hpux/onlinedocs/B2355-90046/00/01/153-con.html&toc=/hpux/onlinedocs/B2355-90046/00/01/153-toc.html&searchterms=trap&queryid=20030519-215144
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2003 07:55 PM
тАО05-19-2003 07:55 PM
Re: Need Syntax and Manual for trap command
trap "commands to be executed" signal_no.
Check man 5 signal, man kill to see if a signal can be trapped.
trap when the said signal is trapped, executes the commands specified.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2003 08:00 PM
тАО05-19-2003 08:00 PM
Re: Need Syntax and Manual for trap command
$ man ksh
$ man signal
Regards
Michael
"When I have trouble spelling, it's called fat finger syndrome"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2003 03:37 AM
тАО05-20-2003 03:37 AM
Re: Need Syntax and Manual for trap command
To easily 'browse' a manual page, do:
man sh-posix | col -b >/tmp/manpage
view /tmp/manpage
Then use "/" to search for a text or pattern and use "n" to go to the next occurence.
In this case:
/trap
n
will (probably) bring you to the desired "trap [arg] [sig]..." section.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2003 05:12 AM
тАО05-20-2003 05:12 AM
Re: Need Syntax and Manual for trap command
below a quote from Professor Brown's lecture notes (http://www.ibilce.unesp.br/courseware/unix/unix14.htm)
Shell procedures can use the trap command to disable a signal or redefine its action. The format of the trap command is,
trap arg signal-list
Arg is a string to be interpreted as a command list and signal-list consists of one or more signal numbers as described by the signal keyword.
Number Signal
0 - exit from shell
1 - HANGUP
2 - INTERRUPT character (DELETE or RUB OUT)
3 - QUIT (ctrl-\)
9 - KILL (cannot be caught or ignored)
11 - segmentation violation
15 - software termination signal
The commands in arg are scanned at least once, so it is wise to use single rather than double quotes to surround these commands.
The following shell procedure lists all files ending in .tmp (in /bin and /usr/bin) and traps signals 2, 3 and 15. If a trap occurs, it prints the name of the current directory.
trap 'echo Directory was `pwd` when interrupted' 2 3 15
for i in /bin /usr/bin
do
cd $i
for files in *.tmp
do
echo $files
done
done
Ensure you know which key can generate a trap signal 2. This might involve reconfiguring some telnet options.
The trap command is frequently used to remove temporary files upon termination of a shell procedure.
temp=$HOME/temp/$$
trap 'rm -f $temp; exit' 0 1 2 3 15
ls > $temp
# commands that use $temp here
In this case, the exit command is used to terminate the shell procedure when the trap occurs. At this time, the temporary file is also removed.
hope this helps!
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2003 07:26 AM
тАО05-20-2003 07:26 AM
Re: Need Syntax and Manual for trap command
Trap is a function of the shell, and not a binary command. The list signals to trap is available with "kill -l". Since it is not an external command, but a shell internal there is no man page for trap. Man signal and man ksh/sh will give you better information. Cshell has very different methods ;)
Regards,
Shannon