- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script debug output
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
тАО07-09-2009 04:48 AM
тАО07-09-2009 04:48 AM
Script debug output
I have a script which generates error. I need to capture the output or the error in a debug mode using set -x. How to capture the error in a file in debug mode using set -x
Thanks & Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 04:55 AM
тАО07-09-2009 04:55 AM
Re: Script debug output
Simply redirect STDERR to your file:
# sh -x ./myscript 2>mytrace
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 04:57 AM
тАО07-09-2009 04:57 AM
Re: Script debug output
Thanks for your reply. The script is called by some real time application and there is some issue with it. So we want to trace the script using set -x and capture the output in temporary file.
Please suggest.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 05:06 AM
тАО07-09-2009 05:06 AM
Re: Script debug output
> The script is called by some real time application and there is some issue with it. So we want to trace the script using set -x and capture the output in temporary file.
The at the top of the script add the two lines shown below ('exec' and 'set'):
# cat ./thescript
#!/usr/bin/sh
exec 2>/var/tmp/errlog.$$
set -x
...
Your script will write it's trace to '/var/tmp/errlog' with the PID of the process appended for multiple runs or instances.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 05:43 AM
тАО07-09-2009 05:43 AM
Re: Script debug output
Also, do we have to type in "set +x" at the end of the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 05:52 AM
тАО07-09-2009 05:52 AM
Re: Script debug output
> will it be stderr(2) or the stdout(1) that will give the relevant data.. please confirm.
As I showed, if you want to capture the trace in a file, you need to redirect STDERR to that file.
> Also, do we have to type in "set +x" at the end of the script.
No, when your script exits, the setting ceases to matter. If you only want some particular section of your code traced, then you can bound it by 'set -x' and 'set +x' accordingly.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 06:35 AM
тАО07-09-2009 06:35 AM
Re: Script debug output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2009 06:37 AM
тАО07-09-2009 06:37 AM
Re: Script debug output
> Thank You James. I appreciate your assistance in this issue.
If you are satistied with the answers you have received, please read:
http://forums.itrc.hp.com/service/forums/helptips.do?#28
Assigning points is both a way of saying "thank you" and a way of showing future readers of your thread what helped you solve your problem.
Regards!
...JRF...