- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Debugging scripts KSH
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-15-2003 05:15 AM
тАО05-15-2003 05:15 AM
are there any tools to execute step by step a KSH script?
sorry for the stupid question :-)
Enrico
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2003 05:20 AM
тАО05-15-2003 05:20 AM
Re: Debugging scripts KSH
See set options in manpage and put
At the start of the script
-p Disables processing of the $HOME/.profile file and
uses the file /etc/suid_profile instead of the ENV
file. This mode is on whenever the effective uid
(gid) is not equal to the real uid (gid). Turning
this off causes the effective uid and gid to be
set to the real uid and gid.
-s Sort the positional parameters.
-t Exit after reading and executing one command.
-u Treat unset parameters as an error when
substituting.
-v Print shell input lines as they are read.
-x Print commands and their arguments as they are
executed.
- Turns off -x and -v options and stops examining
arguments for options.
-- Do not change any of the options; useful in
setting $1 to a value beginning with -. If no
arguments follow this option, the positional
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2003 05:25 AM
тАО05-15-2003 05:25 AM
Re: Debugging scripts KSH
set -x
in the second line of your script.
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2003 05:36 AM
тАО05-15-2003 05:36 AM
SolutionSteve has listed some of the more useful options.
You can leverage these without modifing your script by simply doing, for example:
# ksh -x yourscript
Another useful technique is to have 'trap' statements in your script for DEBUG and ERR. For example:
# trap 'echo Debug handler entered' DEBUG
# trap 'echo Error handler entered' ERR
See the 'sh-posix' or 'ksh' man pages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2003 05:46 AM
тАО05-15-2003 05:46 AM
Re: Debugging scripts KSH
another little trick.
If after setting the debug mode (i call it so) you want to log everything, you can use the "script filename" command.
this utility let you dump all video output (std out and std err) and your input to the file mentioned, very usefull for debugging purpose.
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2003 06:16 AM
тАО05-15-2003 06:16 AM
Re: Debugging scripts KSH
Here's another example of how you might leverage the DEBUG signal to monitor your script. Remember that the trap could be set and reset around regions of your code. Hence, consider this example
#/usr/bin/ksh
echo "hello world!"
[ X"$1" = X-d ] && trap 'echo "@line-${LINENO}' DEBUG
echo "where am I?"
date
[ X"$1" = X-d ] && trap '' DEBUG
echo "debug mode off"
date
echo "where am I?"
exit 0
Run the script this way:
# ./my.sh
...then, with debug mode on:
# ./my.sh -d
Regards!
...JRF...